Here you can find the source of rtrim(String s)
Parameter | Description |
---|---|
s | the string to be processed |
public static String rtrim(String s)
//package com.java2s; public class Main { /**//from w ww . j a va 2 s. c o m * Remove all trailing blanks. * @param s the string to be processed * @return the result of the processing */ public static String rtrim(String s) { int index = s.length() - 1; while (index >= 0 && isSpace(s.charAt(index))) index--; return s.substring(0, index + 1); } /** * Check whether a character is a blank. * @param c the character to be checked * @return the result of the test */ public static boolean isSpace(char c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t'; } }