Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"FileNotFoundException", but it's there...

 
Kari Nordmann
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a task in which I put pieces of a sudokuprogram together.
Right now I'm trying to get the program to read sudokus from files instead of creating them manually.
The problem is that when I try to run the method lesFraFil(readfromfile), I just keep gettings errors like FileNotFoundException, even before I run the program (using Eclipse). The file is there, it's right in the same folder where the .java's and .class' to the program are.
I get the feeling the error is actually casued by something completely different than the file not being found, so I don't really understand the error... Can anyone explain what is wrong?

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing to do is to put the lineafter the lineto check exactly what file the program is trying to access.
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The File may be present, but you lesFraFil method throws a filenotfoundexception. but you calling method doesn't handle it. It is failing at compile time only,not at run time
Since you are throwing the exception in your called method(lesFraFil ), the calling method should catch it and do somethg
Jhakda
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well spotted Jhakda. I guess that's what the OP meant when he said 'I just keep gettings errors like FileNotFoundException, even before I run the program'
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is right. The eclipse IDE might have been asking you to 'deal' with it by handling the errors in the statement which calls the method throwing such exceptions!
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Method SudokuBrett has to either catch or rethrow all exceptions thrown by the lesFraFil method.

Now the compiler will only complain about FileNotFoundException and IOException, because the other ones are unchecked exceptions. If you don't know what that means, the search on this forum, Google or Wikipedia can tell you all you need to know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic