Here you can find the source of rtrim(String str)
public static String rtrim(String str)
//package com.java2s; /*//ww w . ja va2 s . com * M2M ServiceFOTA ONM version 1.0 * * Copyright ? 2014 kt corp. All rights reserved. * * This is a proprietary software of kt corp, and you may not use this file except in * compliance with license agreement with kt corp. Any redistribution or use of this * software, with or without modification shall be strictly prohibited without prior written * approval of kt corp, and the copyright notice above does not evidence any actual or * intended publication of such software. */ public class Main { public static String rtrim(String str) { int index = str.length(); while (' ' == str.charAt(--index)) ; if (index < str.length()) str = str.substring(0, index + 1); return str; } }