List of utility methods to do String Truncate
String | truncatePrefixFromPath(String fileName) truncate Prefix From Path String pathPrefixComponent[] = fileName.split(":", 2); if (pathPrefixComponent.length == 1) { return pathPrefixComponent[0]; } else { return pathPrefixComponent[1]; |
String | truncatePunctuation(String authority) truncate Punctuation while (authority.startsWith("(")) authority = authority.substring("(".length()).trim(); while (authority.endsWith("(")) authority = authority.substring(0, (authority.length() - "(".length())).trim(); while (authority.endsWith(",")) authority = authority.substring(0, (authority.length() - ",".length())).trim(); while (authority.endsWith(")")) authority = authority.substring(0, (authority.length() - ")".length())).trim(); ... |
String | truncateSentence(String input, int length) truncate Sentence int length2 = length; while (length2 > 0) { char c = (input.charAt(length)); if (c < 'A' || c > 'z') { length2 = 0; } else { length--; length2--; ... |
String | truncateShortMessage(final String message) truncate Short Message if (null == message) { return ""; } else if (message.length() > MAX_SHORT_MESSAGE_LENGTH) { return message.substring(0, MAX_SHORT_MESSAGE_LENGTH); } else { return message; |
String | truncateStr(String str, int maxNumChars) Truncates a string and adds an ellipse string to the end. final String ellipse = "..."; if (str == null) return ""; if (str.length() >= maxNumChars) { StringBuffer newStr = new StringBuffer(maxNumChars); newStr.append(str.substring(0, maxNumChars - 1 - ellipse.length())); newStr.append(ellipse); return newStr.toString(); ... |
String | truncateString(final String str, final int iMaxLength) Truncates a long string, which cannot be shown in full to the user. String strRet = null; if (str != null) { if (str.length() <= iMaxLength) { strRet = str; } else if (iMaxLength > 50) { final String strAdd = "... (total length of " + str.length() + " characters)"; strRet = str.substring(0, iMaxLength - strAdd.length()) + strAdd; } else if (iMaxLength > 3) { ... |
String | truncateString(int length, String srcString) truncate String return srcString.length() < length ? srcString : srcString.substring(0, length - 10) + "..." + srcString.substring(srcString.length() - 10, srcString.length()) + "[Truncated]"; |
String | truncateString(String description, int length) Will truncated the string to 35 characters in length adding an ellipsis for the last three characters. String truncated = ""; if (description.length() > length) { truncated = description.substring(0, length - 3); truncated = truncated + "..."; } else { truncated = description; return truncated; ... |
String | truncateString(String errCode, int length, boolean isRight) truncate String if (!isEmpty(errCode)) { if (length >= errCode.length()) { return errCode; } else { String subString = ""; if (isRight) { subString = errCode.substring(0, length); return subString; ... |
String | truncateString(String inStr, int maxValue) truncate String if (inStr == null) return null; int endIndex = inStr.length(); if (inStr.length() > maxValue) { endIndex = maxValue - 3; String outStr = inStr.substring(0, endIndex); if (inStr.length() > maxValue) ... |