How to remove the \n, \t and spaces between the strings in java?

前端 未结 2 475
鱼传尺愫
鱼传尺愫 2020-12-21 10:08

How do you remove the \\n, \\t and spaces between strings in java?

2条回答
  •  独厮守ぢ
    2020-12-21 10:37

    Use String.replaceAll with a regular expression to remove all whitespace:

    s = s.replaceAll("\\s+", "");
    

提交回复
热议问题