开发者

Java equivalent to C#'s @ symbol for escaping \ [duplicate]

开发者 https://www.devze.com 2023-03-27 19:46 出处:网络
This question already has answers here:开发者_Python百科 Closed 11 years ago. Possible Duplicate: Java equivalent of C#'s verbatim strings with @
This question already has answers here: 开发者_Python百科 Closed 11 years ago.

Possible Duplicate:

Java equivalent of C#'s verbatim strings with @

An example in C# would be:

string path = @"C:\myfile.txt";

Another example is the answer to this question.


There is nothing equivalent to the @ symbol in Java - you must escape each and every backslash in a String literal.


String path = "C:\\myfile.txt";
// or "C:/myfile.txt";
// or "C:" + System.getProperty("file.separator") + "myfile.txt";
0

精彩评论

暂无评论...
验证码 换一张
取 消