Removing whitespace from strings in Java

前端 未结 30 2217
一个人的身影
一个人的身影 2020-11-22 05:01

I have a string like this:

mysz = \"name=john age=13 year=2001\";

I want to remove the whitespaces in the string. I tried trim()

30条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 05:38

    If you prefer utility classes to regexes, there is a method trimAllWhitespace(String) in StringUtils in the Spring Framework.

提交回复
热议问题