How to split a String array?

后端 未结 4 974
醉梦人生
醉梦人生 2021-02-20 00:33

Intention is to take a current line (String that contains commas), replace white space with \"\" (Trim space) and finally store split String elements into the array.

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 00:57

    I think you want replaceAll rather than replace.

    And replaceAll("\\s","") will remove all spaces, not just the redundant ones. If that's not what you want, you should try replaceAll("\\s+","\\s") or something like that.

提交回复
热议问题