List of utility methods to do String Truncate
String | truncateString(String text, int truncateAt) Truncates a string. if (text == null) return null; if (truncateAt < _TRUNCATE_AT_MINIMUM) truncateAt = _TRUNCATE_AT_MINIMUM; if (text.length() > truncateAt) { text = text.substring(0, truncateAt - _ELLIPSIS_LENGTH) + _ELLIPSIS; return text; ... |
String | truncateStringAt(String source, int len) Returns a new string that is the first len chars of source if (source.length() < len) { return source; return source.substring(0, len); |
String | truncateStringChars(String strIn, String substituteChars, int maxChars, boolean keepRightSide) Truncates a string to the number of characters in maxChars The character count includes the substitute characters (which will only be added if the string is truncated) if (strIn.length() <= maxChars) { return strIn; strIn = strIn.replaceAll(" ", ""); if (strIn.length() <= maxChars) { return strIn; if (keepRightSide) { ... |
String | truncateStringToUtf8(final String original, final int maxBytes) Truncates the specified string to fit in the specified maximum number of UTF-8 bytes. final int length = original.length(); int newLength = 0; int currentBytes = 0; while (newLength < length) { final char c = original.charAt(newLength); boolean isSurrogate = false; if (c <= 0x7f) { ++currentBytes; ... |
String | truncateSubjectText(String subject) truncate Subject Text int limit = 60; if (subject.length() > limit) { subject = subject.substring(0, limit) + "..."; return subject; |
String | truncateTestName(String test) truncate Test Name return (test.length() <= 27) ? test : test.substring(0, 28);
|
String | truncateText(String str, int lower, int upper, String appendToEnd) truncate Text String str2 = removeHTML(str, false); if (upper < lower) { upper = lower; if (str2.length() > upper) { int loc; loc = str2.lastIndexOf(' ', upper); if (loc >= lower) { ... |
String | truncateText(String text, int maxCharLength) truncate Text return truncateText(text, maxCharLength, "..."); |
String | truncateTime(String dateString) truncate Time String retVal = dateString; if (dateString != null) { int i = dateString.indexOf(" "); if (i > -1) { retVal = dateString.substring(0, i); System.out.println("******* at line 28 of AdministeredItemUtil.java" + retVal); ... |
String | truncateToFirstLine(String string) Truncate a string to the first '\n' character. int newLineIndex = string.indexOf('\n'); if (newLineIndex == -1) { return string; return String.format("%s...", string.substring(0, newLineIndex)); |