以下代码:
final String INVALID_ESCAPE="\\";
System.out.println(String.format("'%s' -> '%s'", INVALID_ESCAPE,
StringEscapeUtils.unescapeJava(INVALID_ESCAPE)));
...产生:
'\' -> ''
在控制台上。由于 '\'
不是有效的转义,我预计在运行时会出现异常。我错过了什么吗?
更新: 在 Apache jira 中填写了错误(?)报告
最佳答案
来自source :
// TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)?
发送补丁;-)
关于java - Apache commons StringEscapeUtils.unescapeJava ("\\")返回 "",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16018235/