Java Utililty Methods String Chomp

List of utility methods to do String Chomp

Description

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

Method

StringchompHeader(String str, String prex)
chomp Header
if (str == null) {
    return "";
if (str.startsWith(prex)) {
    return str.substring(prex.length());
return str;
StringchompLast(String str)
chomp Last
return chompLast(str, "\n");
StringchompLast(String str, String sep)

Remove a value if and only if the String ends with that value.

if (str.length() == 0) {
    return str;
String sub = str.substring(str.length() - sep.length());
if (sep.equals(sub)) {
    return str.substring(0, str.length() - sep.length());
return str;
...
StringchompNewLine(String line)
chomp New Line
return line.replaceAll("(\r|\n\r?)$", "");