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

时间:2015-01-09 05:36:52

标签: java

我正在尝试上传和检索resume.while检索简历它显示错误将项目合规性和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 个答案:

答案 0 :(得分:0)

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

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

希望这有帮助!

祝你好运!