Java equivalent of Python repr()?

后端 未结 9 1919
醉酒成梦
醉酒成梦 2020-12-18 18:18

Is there a Java method that works like Python\'s repr? For example, assuming the function were named repr,

\"foo\\n\\tbar\".repr()

would re

9条回答
  •  渐次进展
    2020-12-18 18:56

    In case you are using Groovy, it provides a similar StringEscapeUtils class as Apache Commons Lang:

    StringEscapeUtils.escapeJava("foo\n\tbar")
    

提交回复
热议问题