is there another way how to remove WhiteSpace Char(s) from String
1) other as I know
myString.trim()
Pattern.compile("\\s");
2) is there another reason(s) search/look for an another/different method as I using
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Guava has a preconfigured
CharMatcherforwhitespace(). It works with unicode as well.Sample usage:
Output:
The CharMatcher also has many other nice features, one of my favorites is the
collapseFrom()method, which replaces multiple occurences with a single character:Output: