Here you can find the source of stripEnd(String str, String stripChars)
public static String stripEnd(String str, String stripChars)
//package com.java2s; public class Main { public static String stripEnd(String str, String stripChars) { int end;/*w w w . j a va 2s . c o m*/ if (str == null || (end = str.length()) == 0) { return str; } if (stripChars == null) { while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) { end--; } } else if (stripChars.length() == 0) { return str; } else { while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) { end--; } } return str.substring(0, end); } public static int indexOf(String str, String searchStr) { if (str == null || searchStr == null) { return -1; } return str.indexOf(searchStr); } }