Raw Strings in Java - for regex in particular. Multiline strings

前端 未结 12 1248
青春惊慌失措
青春惊慌失措 2020-12-01 02:13

Is there any way to use raw strings in Java (without escape sequences)?

(I\'m writing a fair amount of regex code and raw strings would make my code immensely more r

12条回答
  •  暖寄归人
    2020-12-01 02:23

    String#getBytes() exposes a copy of the internal byte array contained in every single String object which actually contains the 16-bit UTF-16 encoded String - the byte array will contain the same string converted to match the platform's default charset. What I'm saying is that I think this is as close to "raw" string as you can ever get in Java.

提交回复
热议问题