Why does .split(“\\”) generate an exception?

前端 未结 5 1447
死守一世寂寞
死守一世寂寞 2021-01-25 03:35

I have a String representing a directory, where \\ is used to separate folders. I want to split based on \"\\\\\":

String address = \"C         


        
5条回答
  •  礼貌的吻别
    2021-01-25 04:14

    Use separators:

    String address = "C:\saeed\test";
    String[] splited = address.split(System.getProperty("file.separator"));
    

提交回复
热议问题