code: public static String chomp(String s) {
      if(s.length() == 0)
        return s;
      int l_1 = s.length() - 1;
      if (s.charAt(l_1) == '\n') {
        return s.substring(0, l_1);
      }
      return s;
    }
docs: Returns the supplied string with any trailing '\n' removed.