我正在编写一个 Java 代码,通过它创建一个 JavaScript 文件。在脚本文件中,我想写
var alertData = "Following characters are not allowed for value. [ $ & + , / : ; =? @ \" < > # % { } | \\ ~ ^ [ ] ` ]";
当我编译代码并调用方法来创建文件时,
Syntax Error: syntax error: > is not valid.
有人可以帮忙吗?
更多代码
StringBuilder sb = new StringBuilder(100);
sb.append("var validationAlertForValues = \"");
sb.append(("Following characters are not allowed for value. [ $ & + , / : ; =? @ \" < > # % { } | \\ ~ ^ [ ] ` ]"));
sb.append("\";\n var validationAlertForKeys = \"");
sb.append(("Following characters are not allowed for key name. [ $ & + , / : ; =? @ \" # % { } | ~ ^ [ ] ` <space< ] "));
FileWriter fstream = null;
BufferedWriter out = null;
try {
fstream = new FileWriter(filePath);
out = new BufferedWriter(fstream);
out.write(sb.toString());
} catch (Exception e) {
log.error("Exception in making JS", e);
}