开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜