Here you can find the source of chomp(String s)
public static String chomp(String s)
//package com.java2s; public class Main { /**/* w w w. j a va 2 s . c o m*/ * Returns the supplied string with any trailing '\n' removed. */ 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; } /** * Returns the result of calling toString() on the supplied Object, but with * any trailing '\n' removed. */ public static String chomp(Object o) { return chomp(o.toString()); } }