Here you can find the source of rightTrim(String value)
private static String rightTrim(String value)
//package com.java2s; public class Main { private static String rightTrim(String value) { if (value == null) { return ""; }//from w ww.j a v a 2 s . c om int length = value.length(); for (int i = length - 1; i >= 0; i--) { if (value.charAt(i) != 0x20) { break; } length--; } return value.substring(0, length); } }