Here you can find the source of rtrim(String str)
Parameter | Description |
---|---|
str | String to be trimmed |
public static String rtrim(String str)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2013, Cloudsmith Inc. * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the copyright holder * listed above, as the Initial Contributor under such license. The text or * such license is available at www.eclipse.org. ******************************************************************************/ public class Main { /**//from w w w . ja v a 2 s .co m * Right trim of a given String * * @param str * String to be trimmed * @return trimmed String */ public static String rtrim(String str) { int len = str.length(); char[] val = str.toCharArray(); int count = len; while (len > 0 && (val[len - 1] <= ' ')) { len--; } return (len < count) ? str.substring(0, len) : str; } }