Here you can find the source of rightTrim(String src)
public static String rightTrim(String src)
//package com.java2s; //License from project: Apache License public class Main { public static String rightTrim(String src) { if (src != null) { char[] chars = src.toCharArray(); for (int i = chars.length - 1; i >= 0; i--) { if ((chars[i] != ' ') && (chars[i] != '\t') && (chars[i] != '\r')) { return src.substring(0, i + 1); }//from w w w. j a va 2 s . co m } return ""; } return src; } }