Using FileReader causes a compiler error “unhandled exception type FileNotFoundException”

后端 未结 6 1053
傲寒
傲寒 2021-01-15 10:01

Ive read a few threads here that relate the same problem, but the solutions arent working. :/

I use Eclipse, here is my program.

package mypackage;
         


        
6条回答
  •  长发绾君心
    2021-01-15 10:43

    Use the file descriptor that you created and verified before creating the file reader. Also, you will probably run into problems using relative paths. Why is the line with the full path commented out? In any case, here is the code:

    if(file1.exists()) {
         log(myfile + " exists. length : " + myfile.length());
         FileReader fr = new FileReader(file1); 
    }
    

提交回复
热议问题