List of utility methods to do String Chop
String[] | chopString(String argString, int argLength) Chops the string into smaller strings with size of argLength. if (argString.length() == 0) { return new String[0]; if (argString.length() <= argLength) { return new String[] { argString }; String[] ret = new String[(int) Math.ceil(argString.length() / argLength)]; int i; ... |
String | chopString(String str, int len) chop String if (str == null || str.length() <= len) { return str; String ret = str.substring(0, len - 1) + "..."; return ret; |
String | chopString(String title, int maxLen) chop String final int length = title.length(); final StringBuilder stringBuilder = new StringBuilder(length + 10); int len = 0; for (int i = 0; i < length; i++) { final char c = title.charAt(i); if (isBreakable(c)) { len = 0; } else { ... |
float | chopToNSignificantDigits(final float original, int no_of_sig_digits) chop To N Significant Digits if (original == 0f) return 0f; final int exp = (int) Math.floor((float) Math.log(Math.abs(original)) / _log_e_10 - no_of_sig_digits + 1f); final double mult = Math.pow(10.0, exp); return (float) (Math.round(original / mult) * mult); |
String | chopTrailingChars(String source, char[] chars) chop Trailing Chars StringBuffer sb = new StringBuffer(source); while (true) { boolean atLeastOneCharWasChopped = false; for (int i = 0; i < chars.length && sb.length() > 0; i++) { if (sb.charAt(sb.length() - 1) == chars[i]) { sb.deleteCharAt(sb.length() - 1); atLeastOneCharWasChopped = true; if (!atLeastOneCharWasChopped) { break; return sb.toString(); |