List of utility methods to do String Truncate
String | truncateWithDefault(String value, int size, String defaultValue) truncateWithDefault. if (isEmpty(value)) { return defaultValue; if (value.length() > size) { return defaultValue; return value; |
String | truncateWithEllipsis(String str, int maxLength) truncate With Ellipsis StringBuilder sb = new StringBuilder(); if (str != null) { sb.append(str); if (str.length() > maxLength) { sb.setLength(maxLength); if (maxLength > 3) { sb.replace(maxLength - 3, maxLength, "..."); return sb.toString(); |
String | truncAtWord(String a_text, int a_length) Truncate a string at a word boundary String text = a_text; if (null != a_text && text.length() > a_length) { int backEnd = 20; if (backEnd > a_length) { backEnd = a_length - 1; int finalLength = a_length; char character; ... |
String | truncString(String in, int len) Simple static method to tuncate Strings to given length. String out = in; if (in != null && len > 0 && in.length() > len) { out = in.substring(0, len); return out; |
String | truncuate(String s, int maximumLength, String append) truncuate if (s.length() > maximumLength) { return s.substring(0, maximumLength - append.length()) + append; return s; |
String | truncVal(String s) trunc Val if (s == null) { return ""; int len = Math.min(s.length(), 10); String postfix = ""; if (s.length() > len) { postfix = "..."; return s.substring(0, len) + postfix; |