Java equivalent of C#'s verbatim strings with @

前端 未结 4 1926
再見小時候
再見小時候 2020-11-30 03:49

Quick question. Is there an equivalent of @ as applied to strings in Java:

For example I can do @\"c:\\afolder\\afile\" in C# and have it ignore the esc

4条回答
  •  孤街浪徒
    2020-11-30 04:13

    Currently it is not supported in Java but could be available in future releases. There was created JEP 326: Raw String Literals at 2018/01/23

    See the progress at https://bugs.openjdk.java.net/browse/JDK-8196004

    Probably some day you will be able to do it with:

    `c:\afolder\afile`
    

    UPDATE: JEP proposed to drop from JDK 12:326: Raw String Literals (Preview) You can read the rationale here: http://mail.openjdk.java.net/pipermail/jdk-dev/2018-December/002402.html

    And more details here https://bugs.openjdk.java.net/browse/JDK-8215682

    The bottom line: There will not be verbatim strings in Java in near future. And even if it will appear it rather will not be ``.

提交回复
热议问题