Removing whitespace from strings in Java

前端 未结 30 2255
一个人的身影
一个人的身影 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:46

    One way to handle String manipulations is StringUtils from Apache commons.

    String withoutWhitespace = StringUtils.deleteWhitespace(whitespaces);
    

    You can find it here. commons-lang includes lots more and is well supported.

提交回复
热议问题