List of utility methods to do String Trim
String | rtrim(final String text, String trimText) rtrim if (text == null) { return null; if (trimText == null) { trimText = " "; int pos = text.length() - 1; for (; pos >= 0; pos--) { ... |
String | trimSuffix(final String text, final String suffix) trim Suffix if (text == null) { return null; if (suffix == null) { return text; if (text.endsWith(suffix)) { return text.substring(0, text.length() - suffix.length()); ... |
String | trimPrefix(final String text, final String prefix) trim Prefix if (text == null) { return null; if (prefix == null) { return text; if (text.startsWith(prefix)) { return text.substring(prefix.length()); ... |
String | trimSpace(String oldString) Method trim space if (null == oldString) return null; if (0 == oldString.length()) return ""; StringBuffer sbuf = new StringBuffer(); int oldLen = oldString.length(); for (int i = 0; i < oldLen; i++) { if (' ' != oldString.charAt(i)) ... |
int | rightTrimSize(String s) Returns the size of substring that does not contain any trailing spaces int i = s.length(); while (i > 0) { i--; if (s.charAt(i) != ' ') { return i + 1; return 0; ... |
String | trim(String s, char c) Removes characters 'c' from the beginning and the end of the string int start = 0; int end = s.length() - 1; while (s.charAt(start) == c) { if (++start >= end) { return ""; while (s.charAt(end) == c) { ... |
String | trim(String trimStr, String trimChars) trim int spIdx = findFirstNotOf(trimStr, trimChars); if (spIdx < 0) { String buf = trimStr; return buf; String trimStr2 = trimStr.substring(spIdx, trimStr.length()); spIdx = findLastNotOf(trimStr2, trimChars); if (spIdx < 0) { ... |
String | trimEnd(String s, String extraChars) Trim characters from only the end of a string. int trimCount = 0; while (trimCount < s.length()) { char ch = s.charAt(s.length() - trimCount - 1); if (Character.isWhitespace(ch) || (extraChars != null && extraChars.indexOf(ch) >= 0)) { trimCount++; } else { break; ... |
String | trimStart(String s, String extraChars) Trim characters from only the beginning of a string. int trimCount = 0; while (trimCount < s.length()) { char ch = s.charAt(trimCount); if (Character.isWhitespace(ch) || (extraChars != null && extraChars.indexOf(ch) >= 0)) { trimCount++; } else { break; ... |
String | betterTrim(String input) better Trim input = input.trim(); if (input.length() == 0) { return input; boolean didChange; do { String oldInput = input; char firstChar = input.charAt(0); ... |