How to escape the backslashes and the automatically generated escape character in file path in java

后端 未结 4 1006
北海茫月
北海茫月 2020-11-28 13:49

I have very small and simple problem but I am not getting solutions on it. Actually I am getting a CSV file path using file chooser. I am entering the data in this csv file

4条回答
  •  时光取名叫无心
    2020-11-28 14:36

    String filepath2=filepath.replace("\","\\") is not valid code - \ is a special character in string literals and needs to be escaped:

    String escapedFilepath = filepath.replace("\\","\\\\"); //double all backslashes
    

提交回复
热议问题