所以我正在从事课程工作,而且我对java很新。
我正在使用一个数据库,该数据库在与文件相关的目录中包含SQL文件。用户需要能够告诉程序查看这些SQL文件,它不能全部查看它们,因为它们有5000-8000个。
String SystemDirectory = "F:/EVE M&R/bin/Resources/Systems";
File[] Directories = new File(SystemDirectory).listFiles(File::isDirectory);
我在第二行收到错误
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on tokens, delete these tokens
M cannot be resolved to a variable
R cannot be resolved to a variable
Syntax error on tokens, delete these tokens
答案 0 :(得分:0)
逃避&:
import org.apache.commons.lang.StringEscapeUtils;
public class testEscapeHTML{
public static void main(String args[]){
String testStr = "< > \" &";
System.out.println("Original : " + testStr);
System.out.println("Escaped : " + StringEscapeUtils.escapeHtml(testStr));
}
}
参考:https://www.mkyong.com/java/how-to-escape-special-characters-in-java/