How to split a String by space

前端 未结 15 1774
傲寒
傲寒 2020-11-22 10:31

I need to split my String by spaces. For this I tried:

str = \"Hello I\'m your String\";
String[] splited = str.split(\" \");

But it doesn\

15条回答
  •  天涯浪人
    2020-11-22 11:08

    Try

    String[] splited = str.split("\\s");
    

    http://download.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html

提交回复
热议问题