List of utility methods to do String Case Convert
String | toLowerCase(String src) Safely convert the string to lowercase. if (src == null) { return null; } else { return src.toLowerCase(); |
String | toUpperCase(String src) Safely convert the string to uppercase. if (src == null) { return null; } else { return src.toUpperCase(); |
String | flipCase(final String s) flip Case final StringBuilder builder = new StringBuilder(s); for (int i = 0; i < s.length(); ++i) { char c = builder.charAt(i); if (Character.isUpperCase(c)) { c = Character.toLowerCase(c); } else if (Character.isLowerCase(c)) { c = Character.toUpperCase(c); builder.setCharAt(i, c); return builder.toString(); |
boolean | matchesIgnoreCase(String str, String query, int startingAt) matches Ignore Case int len = query.length(); for (int i = 0; i < len; i++) { if (Character.toUpperCase(query.charAt(i)) != Character .toUpperCase(str.charAt(startingAt + i))) { return false; return true; ... |
String | lowerCase(String str) lower Case if (str == null) { return null; return str.toLowerCase(); |
String | upperCase(String str) upper Case if (str == null) { return null; return str.toUpperCase(); |
boolean | endsWithIgnoreCase(String source, String suffix) Whether the given source string ends with the given suffix, ignoring case. if (isEmpty(suffix)) return true; if (isEmpty(source)) return false; if (suffix.length() > source.length()) return false; return source.substring(source.length() - suffix.length()) .toLowerCase().endsWith(suffix.toLowerCase()); ... |
boolean | endsWithIgnoreCase(final String target1, final String target2) ends With Ignore Case if (target1 == null || target2 == null) { return false; int length1 = target1.length(); int length2 = target2.length(); if (length1 < length2) { return false; String s1 = target1.substring(length1 - length2); return s1.equalsIgnoreCase(target2); |
boolean | startsWithIgnoreCase(final String target1, final String target2) starts With Ignore Case if (target1 == null || target2 == null) { return false; int length1 = target1.length(); int length2 = target2.length(); if (length1 < length2) { return false; String s1 = target1.substring(0, target2.length()); return s1.equalsIgnoreCase(target2); |
String | toTitleCase(String s) Converts a string into title case. StringBuilder titleCase = new StringBuilder(); boolean nextTitleCase = true; for (char c : s.toCharArray()) { if (Character.isSpaceChar(c)) { nextTitleCase = true; } else if (nextTitleCase) { c = Character.toTitleCase(c); nextTitleCase = false; ... |