Here you can find the source of rightTrim(final String input, final char charToTrim)
public static String rightTrim(final String input, final char charToTrim)
//package com.java2s; /*//w w w .j a va 2 s . c o m * @author Fabio Zadrozny * Created: June 2005 * License: Common Public License v1.0 */ public class Main { /** * Removes the occurrences of the passed char in the beggining of the * string. */ public static String rightTrim(final String input, final char charToTrim) { int len = input.length(); final int st = 0; final int off = 0; final char[] val = input.toCharArray(); while (st < len && val[off + len - 1] == charToTrim) { len--; } return input.substring(0, len); } }