Java Utililty Methods String Chop

List of utility methods to do String Chop

Description

The list of methods to do String Chop are organized into topic(s).

Method

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;
...
StringchopString(String str, int len)
chop String
if (str == null || str.length() <= len) {
    return str;
String ret = str.substring(0, len - 1) + "...";
return ret;
StringchopString(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 {
...
floatchopToNSignificantDigits(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);
StringchopTrailingChars(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();