aspose file tools*
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""FileNotFoundException", but it Watch ""FileNotFoundException", but it New topic
Author

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

Kari Nordmann
Ranch Hand

Joined: Feb 12, 2007
Posts: 38
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

Joined: Aug 05, 2005
Posts: 3561
    
  15
The first thing to do is to put the lineafter the lineto check exactly what file the program is trying to access.


Joanne
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
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


If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3561
    
  15
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

Joined: Apr 20, 2006
Posts: 3344

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!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: "FileNotFoundException", but it's there...