FileNotFound即使File确实存在

时间:2013-08-14 06:47:53

标签: file java.util.scanner filenotfoundexception readfile

对不起草率的代码,它只是一个测试项目,我已经在这个bug上工作至少一个星期了

public static void main(String[] args){
    // TODO Auto-generated method stub
    List<Report> report =  new ArrayList<Report>();
    Report test = new Report();
    File file = new File("testByte.txt");
    Scanner inputFile;
    try {
        inputFile = new Scanner(new File("port.txt"));

        while(inputFile.hasNext())
        {
                test.LoadFromFile(inputFile);
                report.add(test);   
        }

        inputFile.close();


        PdfMaker pdf = new PdfMaker(report);

        try {
            pdf.createLog();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DocumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }



    try
    {
        boolean check = true;
        FileOutputStream output = new FileOutputStream(file);

        for(int i = 0; i < report.size(); i++)
        {
            report.get(i).WriteToFile(output, check);
            check = false;
        }

    }catch(IOException e)
    {
        e.printStackTrace();
    }
}

}

我在行上找到了文件未找到错误

FileNotFoundException(Throwable)。(String)line:264

inputFile = new Scanner(new File("port.txt");

我已经检查了文件的属性,一切都结束了

它位于相应的文件夹

源路径确实将workbench文件夹作为路径。

如果有人能指出我解决这个问题的方向,那将是非常有帮助的,因为我浪费了数小时搜索互联网。

*我打赌这很简单,我只是盲目地看到它

0 个答案:

没有答案
相关问题