Reputation: 20620
C# has the @ string literal to flexibly handle escape characters in strings. Is there anything like that in Java?
Upvotes: 5
Views: 1432
Reputation: 533620
Java supports path separators from UNIX which don't need to be escaped. e.g.
"c:/my/file.txt"
works fine on windows (and unix if you have a directory called c:
)
The chose to use \
rather than /
as a path separator like just about every other operating system before or since, is a pet hate of mine. ;) http://en.wikipedia.org/wiki/Backslash
Upvotes: 2
Reputation: 62449
If only I had a nickle for every time I need this in Java...
If you're doing a Regex operation consider Pattern.quote
as a replacement.
Upvotes: 2
Reputation: 887657
This is called a verbatim string literal.
Java does not have such a feature.
Upvotes: 4