I would like to parse a text file or a java property which contains text such as: "test\n123\t456" to the equivalent if it were written in String test = "test\n123\t456";
i.e. I want the byte开发者_Python百科s to be the same when the text is read from a file compared to compiled in a java class.
I hope this makes sense,
-- Steven
Apache Commons have StringEscapeUtils.unescapeJava method.
In my IDE, if I paste into the middle of a string it turns tabs into \t and newlines into \n for you. I suggest you try that.
For example, if I paste
test
123
456
into a string it becomes
"test\n" +
"123\n" +
"456"
精彩评论