Android examples for java.lang:String Strip
trim Trailing Whitespace from a string
import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static CharSequence trimTrailingWhitespace(CharSequence text) { /* Check for empty string */ if (text.length() == 0) { return text; }//from w ww.j a v a2 s . c o m while (text.charAt(text.length() - 1) == '\n') { text = text.subSequence(0, text.length() - 1); } return text; } }