How to escape forward slash in java so that to use it in path

后端 未结 5 2144
生来不讨喜
生来不讨喜 2020-12-19 14:53

I am trying to escape forward slash in String which can be used in path using Java.
For example: String:: \"Test/World\"
Now I want to use above string

5条回答
  •  攒了一身酷
    2020-12-19 15:12

    In order to escape a character in Java use "\" for example:

    String strPath = "directory\\file.txt".
    

    I believe you do not need to escape forward slashes such as: "/"

提交回复
热议问题