Here you can find the source of rightTrimSize(String s)
Parameter | Description |
---|---|
s | the string |
public static int rightTrimSize(String s)
//package com.java2s; public class Main { /**/*from w w w . j a v a2 s . co m*/ * Returns the size of substring that does not contain any trailing spaces * @param s the string * @return trimmed size */ public static int rightTrimSize(String s) { int i = s.length(); while (i > 0) { i--; if (s.charAt(i) != ' ') { return i + 1; } } return 0; } }