Java String Chop chop(String line)

Here you can find the source of chop(String line)

Description

chop

License

Open Source License

Declaration

public static String chop(String line) 

Method Source Code

//package com.java2s;

public class Main {
    public static String chop(String line) {
        if (line.endsWith("\r\n")) {
            return line.substring(0, line.length() - 2);
        }//from   w  w w.j  av  a 2 s .c  om

        if (line.endsWith("\n")) {
            return line.substring(0, line.length() - 1);
        }

        if (line.endsWith("\r")) {
            return line.substring(0, line.length() - 1);
        }

        return line;
    }
}

Related

  1. chop(double[][] a, double precision)
  2. chop(final String source)
  3. chop(String aString)
  4. chop(String s)
  5. chop(String s, int i)
  6. chop(String s, int maxLength)
  7. chop(String src, String delim)