List of utility methods to do String Truncate
String | truncate(String input, int size) truncates a String to the specified length if (input != null) { int len = input.length(); if (len <= size) { return input; } else { return input.substring(0, size) + "..."; } else { ... |
String | truncate(String message) truncate if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) { return message.substring(0, message.lastIndexOf(".")); message = message.substring(0, 495); if (message.lastIndexOf(".") < 500 && message.lastIndexOf(".") != -1) { return message.substring(0, message.lastIndexOf(".")); return message + "..."; ... |
String | truncate(String message, int length, boolean includeCount) truncate if (message == null) { return null; if (message.length() <= length) { return message; String result = message.substring(0, length) + "..."; if (includeCount) { ... |
String | truncate(String message, String substring) This method is typically used to remove system-specific text from error messages, so that the error messages can be checked in a system-independent fashion. int i = message.indexOf(substring); if (i < 0) { return message; return message.substring(0, i + substring.length()) + "..."; |
String | truncate(String original, int number) Keeps the 'number' first characters, and might be useful to keep your user's privacy : If number is bigger than the size of the String, the whole string is kept : If number==0, the function returns an empty string. if (number < 0) { throw new IllegalArgumentException("number :" + number + " is <0"); if (original == null) { throw new IllegalArgumentException("original string is null"); String newLastName = original.length() >= number ? original.substring(0, number) : original; return newLastName; ... |
String | truncate(String original, String ellipsis, int maxLength) Truncates a String , and if necessary adds an ellipsis to the end of the string. if (original.length() > maxLength) { if (ellipsis == null) { ellipsis = "..."; return original.substring(0, maxLength - ellipsis.length()) + ellipsis; return original; |
String | truncate(String originalString, int size) If the size of the original string is larger than the passed in size, this method will remove the vowels from the original string. if (originalString.length() <= size) { return originalString; String vowels = "AaEeIiOoUu"; StringBuilder newStringBufferTmp = new StringBuilder(originalString.length()); int counter = originalString.length() - size; for (int index = (originalString.length() - 1); index >= 0; index--) { if (vowels.indexOf(originalString.charAt(index)) == -1) { ... |
String | truncate(String s) truncate return truncate(s, MAX_CONTENT_LENGTH);
|
String | truncate(String s) truncate return truncate(s, 15);
|
String | truncate(String s, int begin, int end) truncate if (isNullOrNone(s)) { return ""; if (begin < 0) { return ""; if (begin >= end) { return ""; ... |