Here you can find the source of rtrim(final String input)
public static String rtrim(final String input)
//package com.java2s; public class Main { public static String rtrim(final String input) { if (input == null) return null; if (input.isEmpty()) return input; int i = input.length() - 1; while (i >= 0 && input.charAt(i) == ' ') --i;/*from www .j a v a 2s .c o m*/ return input.substring(0, i + 1); } }