public static String chop(final String str) {
        if (N.isNullOrEmpty(str)) {
            return str;
        }

        final int strLen = str.length();

        if (strLen < 2) {
            return N.EMPTY_STRING;
        }

        final int lastIdx = strLen - 1;

        if (str.charAt(lastIdx) == N.CHAR_LF && str.charAt(lastIdx - 1) == N.CHAR_CR) {
            return str.substring(0, lastIdx - 1);
        } else {
            return str.substring(0, lastIdx);
        }
    }
public static String chop ( final String str ) { if ( N . isNullOrEmpty ( str ) ) { return str ; } final int strLen = str . length ( ) ; if ( strLen < 2 ) { return N . EMPTY_STRING ; } final int lastIdx = strLen - 1 ; if ( str . charAt ( lastIdx ) == N . CHAR_LF && str . charAt ( lastIdx - 1 ) == N . CHAR_CR ) { return str . substring ( 0 , lastIdx - 1 ) ; } else { return str . substring ( 0 , lastIdx ) ; } }
<p>
Remove the last character from a String.
</p>

<p>
If the String ends in {@code \r\n}, then remove both of them.
</p>

<pre>
StrUtil.chop(null)          = null
StrUtil.chop("")            = ""
StrUtil.chop("abc \r")      = "abc "
StrUtil.chop("abc\n")       = "abc"
StrUtil.chop("abc\r\n")     = "abc"
StrUtil.chop("abc")         = "ab"
StrUtil.chop("abc\nabc")    = "abc\nab"
StrUtil.chop("a")           = ""
StrUtil.chop("\r")          = ""
StrUtil.chop("\n")          = ""
StrUtil.chop("\r\n")        = ""
</pre>

@param str
the String to chop last character from, may be null
@return String without last character, {@code null} if null String input