1

重複の可能性:
文字列を Java 文字列リテラルに変換するにはどうすればよいですか?

文字列を受け取り、対応する文字列リテラルに変換するライブラリ関数はありますか? 例:

Please say\ask "What?" three times!->"Please say\\ask \"What?\" three times!"

4

1 に答える 1

7

commons lang StringUtils はそれを行うと思います

http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringEscapeUtils.html

于 2011-07-21T14:47:28.210 に答える