java如何解决JRE旧版本中的enhancedforloop错误?
我正在尝试上传和检索简历。在检索resume时,它显示了将项目符合性和JRE更改为5.0的错误。。。如何在不更新jdk&;的情况下解决此问题;jre版本
这是我的代码
import java.io.File;
public class ReadFilesFromFolder
{
public static File folder = new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\workspace\\uploadfile\\WebContent\\WEB-INF\\filedir\\");
static String temp = "";
public static void main(String[] args)
{
System.out.println("Reading files under the folder "+ folder.getAbsolutePath());
listFilesForFolder(folder);
}
public static void listFilesForFolder(final File folder)
{
for (final File fileEntry : folder.listFiles())
{
if (fileEntry.isDirectory())
{
// System.out.println("Reading files under the folder "+folder.getAbsolutePath());
listFilesForFolder(fileEntry);
}
else
{
if (fileEntry.isFile())
{
temp = fileEntry.getName();
if ((temp.substring(temp.lastIndexOf('.') + 1, temp.length()).toLowerCase()).equals("txt"))
System.out.println("File= " + folder.getAbsolutePath()+ "\\" + fileEntry.getName());
}
}
}
}
}
# 1 楼答案
如果出现错误
Change project compliance and JRE to 5.0
,则需要通过以下步骤更改编译器设置希望这有帮助
祝你好运