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

double[][]chop(double[][] a, double precision)
Sets all elements of matrix which is less than precision to zero
int n = a.length;
for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
        if (Math.abs(a[i][j]) < precision) {
            a[i][j] = 0;
return a;
Stringchop(final String source)
chop
return chop(source, "/"); 
Stringchop(String aString)
Chops off the very last character of the given string.
if (aString == null) {
    return null;
if (aString.length() == 0) {
    return "";
if (aString.length() == 1) {
    return "";
...
Stringchop(String line)
chop
if (line.endsWith("\r\n")) {
    return line.substring(0, line.length() - 2);
if (line.endsWith("\n")) {
    return line.substring(0, line.length() - 1);
if (line.endsWith("\r")) {
    return line.substring(0, line.length() - 1);
...
Stringchop(String s)
chop
if (s == null) {
    return (null);
if (s.length() == 1) {
    return (new String());
s = s.substring(0, (s.length() - 1));
return (s);
...
Stringchop(String s, int i)
Chop i characters off the end of a string.
return chop(s, i, EOL);
Stringchop(String s, int maxLength)
Return the original string if it is shorter than maxLength, otherwise return a substring with length maxLength.
if (s == null)
    return null;
if (maxLength <= s.length())
    return s;
return s.substring(0, maxLength - 1) + " ...";
Stringchop(String src, String delim)
return prefix string by delim(remove delim string and its following charactors).
int index = -1;
if (0 <= (index = src.lastIndexOf(delim))) {
    return src.substring(0, index);
} else {
    return src;
Stringchop(String str)
chop
if (str == null) {
    return null;
int strLen = str.length();
if (strLen < 2) {
    return "";
int lastIdx = strLen - 1;
...
Stringchop(String str)

Remove the last character from a String.

if ("".equals(str)) {
    return "";
if (str.length() == 1) {
    return "";
int lastIdx = str.length() - 1;
String ret = str.substring(0, lastIdx);
...