Here you can find the source of chomp(String str)
public static String chomp(String str)
//package com.java2s; public class Main { /** Removes last character if it is a newline. Like Perl's <code>chomp</code>. */ public static String chomp(String str) { if (str.endsWith("\n")) { return str.substring(0, str.length() - 1); } else {/* w w w .ja va2s. co m*/ return str; } } }