code: public static String chomp(String str, String separator) {
        if (isEmpty(str) || separator == null) {
            return str;
        }
        if (str.endsWith(separator)) {
            return str.substring(0, str.length() - separator.length());
        }
        return str;
    }
docs: <p>Removes <code>separator</code> from the end of
  <code>str</code> if it's there, otherwise leave it alone.</p>
  
  <p>NOTE: This method changed in version 2.0.
  It now more closely matches Perl chomp.
  For the previous behavior, use {@link #substringBeforeLast(String, String)}.
  This method uses {@link String#endsWith(String)}.</p>
  
  <pre>
  GosuStringUtil.chomp(null, *)         = null
  GosuStringUtil.chomp("", *)           = ""
  GosuStringUtil.chomp("foobar", "bar") = "foo"
  GosuStringUtil.chomp("foobar", "baz") = "foobar"
  GosuStringUtil.chomp("foo", "foo")    = ""
  GosuStringUtil.chomp("foo ", "foo")   = "foo "
  GosuStringUtil.chomp(" foo", "foo")   = " "
  GosuStringUtil.chomp("foo", "foooo")  = "foo"
  GosuStringUtil.chomp("foo", "")       = "foo"
  GosuStringUtil.chomp("foo", null)     = "foo"
  </pre>
  
  @param str  the String to chomp from, may be null
  @param separator  separator String, may be null
  @return String without trailing separator, <code>null</code> if null String input