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: MIT License public class Main { public static String rtrim(String s) { int i = s.length() - 1; while (i >= 0 && Character.isWhitespace(s.charAt(i))) { i--;// w ww . j a va 2 s . c om } return i(s, 0, i + 1); } public static String rtrim(String s, char character) { int i = s.length() - 1; while (i >= 0 && s.charAt(i) == character) { i--; } return i(s, 0, i + 1); } public static String i(String s, int begin, int end) { if (s == null) return null; int len = s.length(); if (begin < 0) begin += len; if (end < 0) end += len; if (begin < 0) begin = 0; if (end < 0) end = 0; if (begin >= len) return ""; if (end > len) end = len; if (end <= begin) return ""; return s.substring(begin, end); } public static String i(String s, int begin) { return i(s, begin, s.length()); } }