Here you can find the source of chomp(String sd, String c)
public static String chomp(String sd, String c)
//package com.java2s; public class Main { public static String chomp(String sd, String c) { if (sd == null) { return null; }//w w w.jav a2 s.c o m if (sd.length() == 0) { return ""; } if (sd.endsWith(c)) { return sd.substring(0, sd.length() - c.length()); } return sd; } }