List of utility methods to do String Truncate
String | truncateMessage(String message, int TRUNCATED_MSG_SIZE) truncate Message if (message != null && message.length() > TRUNCATED_MSG_SIZE) return message.substring(0, TRUNCATED_MSG_SIZE) + "..."; else return message; |
String | truncateMessageIn50000Characters(final String message) truncate Message In Characters return truncateMessageInCharacters(message, 50000);
|
String | truncateName(String name) truncate Name if (name == null || name.length() <= 12) return name; else return name.substring(0, 12); |
String | truncateName(String name) Returns name truncated to DISPLAY_WIDTH. if (name.length() > DISPLAY_WIDTH) { return name.substring(0, DISPLAY_WIDTH); } else { return name; |
String | truncateNicely(String s, int n, String suffix) Nicely truncate a string. int l = s.length(); if (s.length() <= n) return s; int sufflen = suffix.length(); for (int i = n - sufflen; i > 0; i--) { char ch = s.charAt(i); if (Character.isWhitespace(ch)) { return s.substring(0, i) + suffix; ... |
String | truncateNicely(String str, int lower, int upper, String appendToEnd) This method based on code from the String taglib at Apache Jakarta. String str2 = removeHTML(str, false); boolean diff = (str2.length() < str.length()); if (upper < lower) { upper = lower; if (str2.length() > upper) { int loc; loc = str2.lastIndexOf(' ', upper); ... |
String | truncateNumberSign(String s) truncate Number Sign if (s.contains("#")) { int i = s.indexOf("#"); return s.substring(0, i); } else { return s; |
String | truncateOnlyText(String text, int position) Truncate a text with HTML tags up to the given position. StringBuilder t = new StringBuilder(); int start = 0; int end = 0; int s = 0; int i = 0, l = 0; int e = 0; char p = ' '; for (; i < text.length(); i++) { ... |
String | truncateOnSpace(String text, Integer length) truncate On Space String retVal = ""; if (text.length() <= length) { retVal = text; } else { StringBuffer b = new StringBuffer(); for (int i = 0; i < text.length(); i++) { if (b.length() >= length && Character.isWhitespace(text.charAt(i))) { b.append("..."); ... |
String | truncateOrPadString(String str) Truncates a String to a specific length or pads it with extra spaces. StringBuffer temp; if (str == null) { temp = new StringBuffer(); } else { temp = new StringBuffer(str); int diff = STR_LENGTH - temp.length(); if (diff > 0) { ... |