Here you can find the source of rightTrim(String s)
public static String rightTrim(String s)
//package com.java2s; //License from project: Open Source License public class Main { public static String rightTrim(String s) { int pos = s.length(); while (--pos >= 0) if (!Character.isWhitespace(s.charAt(pos))) break; return s.substring(0, pos + 1); }/*from www. jav a 2 s . co m*/ }