Java equivalent to C#'s @ symbol for escaping \ [duplicate]
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";
精彩评论