Eclipse has an option so that copy-paste of multi-line text into String literals will result in quoted newlines:html
Preferences/Java/Editor/Typing/ "Escape text when pasting into a string literal"java
添加一个字符串到eclipse里面,自动加上转义eclipse
好比给一个String 赋值 一段xml,自动转义。spa
String xml = <state name="state"> <paths> <path to="1" expr="i==1"/> <path to="2" expr="i==2"/> </paths> </state>
变成code
String xml = xml
String xml = "<state name=\"state\">\n" + " <paths>\n" + " <path to=\"1\" expr=\"i==1\"/>\n" + " <path to=\"2\" expr=\"i==2\"/>\n" + " </paths>\n" + " </state>";