how to split the string in java

后端 未结 10 1699
梦如初夏
梦如初夏 2020-12-11 10:44

how to split the string in java in Windows? I used Eg.

String directory=\"C:\\home\\public\\folder\";
String [] dir=direct.split(\"\\\");
         


        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 11:14

    It's because of the backslash. A backslash is used to escape characters. Use

    split("\\")
    

    to split by a backslash.

提交回复
热议问题