Here you can find the source of rtrim(String str)
public static String rtrim(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String rtrim(String str) { int i = str.length(); while (i > 0) { switch (str.charAt(i - 1)) { case ' ': case '\t': i--;//from w w w . java 2 s . c o m continue; } break; } return str.substring(0, i); } }