how to split the string in java

后端 未结 10 1693
梦如初夏
梦如初夏 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:31

    I guess u can use the StringTokenizer library

    String directory="C:\home\public\folder"; 
    String [] dir=direct.split("\");
    StringTokenizer token = new StringTokenizer(directory, '\');
    while(token.hasTokens()
    {
        String s = token.next();
    }
    

    This may not be completely correct syntactically but Hopefully this will help.

提交回复
热议问题