What is the copy in Java from a C # @ string literal?

C # has an @ string literal to flexibly handle escape characters in strings. Is there something similar in Java?

+4
source share
4 answers

No. You will need to avoid lines.

+6
source

This is called a string literal.
Java does not have this capability.

+4
source

If I had nickel for every time I need it in Java ...

If you are performing a Regex operation, consider Pattern.quote as a replacement.

+2
source

Java supports UNIX path separators that do not require escaping. eg.

 "c:/my/file.txt" 

works fine on windows (and unix if you have a directory named c:

You decided to use \ , and not / as a path separator, for example, in just about any other operating system before or after, is my home hate .;) http://en.wikipedia.org/wiki/Backslash

+2
source

Source: https://habr.com/ru/post/1384606/


All Articles