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
Use the static method escapeJava from the StringEscapeUtils class in Apache Commons Text.
escapeJava
StringEscapeUtils
String repr = "\"" + StringEscapeUtils.escapeJava(myString) + "\"";