如何解决 JRE 旧版本中的增强型循环错误



我正在尝试上传和检索简历。检索简历时显示错误 将项目合规性和 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());
                }
            }
        }
    }
  }

如果您收到错误Change project compliance and JRE to 5.0则需要通过以下步骤更改编译器设置

Window->preferences->Java->Compiler-> and change the compiler compliance level to 1.5

希望这有帮助!

祝你好运!

最新更新