Here you can find the source of rtrim(String s, char character)
public static String rtrim(String s, char character)
//package com.java2s; //License from project: Open Source License public class Main { public static String rtrim(String s, char character) { int i = s.length() - 1; while (i >= 0 && (s.charAt(i)) == character) { i--;/*from w w w . ja v a 2 s .c om*/ } return s.substring(0, i + 1); } }