• Post Reply Bookmark Topic Watch Topic
  • New Topic

handle FileNotFoundException  RSS feed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm calling a method that need to open up the af.sh file.
Because the file does not exist, I get error:

java.io.FileNotFoundException: \file\af.sh (The system cannot find the path specified)

I can't change this method but I want to run all other parts of the method.
Is there anything I can do to catch this exception while continue running the method?
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't change this method
Why?
You can put the rest of the code in catch block but i m not sure that is a recommended procedure!
 
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ellen fish:

I can't change this method but I want to run all other parts of the method.


Then provide the code with things they want !!
I mean to say , provide with dummy OR look like file , named 'af.sh' and saved it into proper directory !! It solves your problem (FileNotFoundException ) but behavior of other part of code is unpredictable !!

Originally posted by Ellen fish:

Is there anything I can do to catch this exception while continue running the method?


Nope, I don't have any idea !
 
Ellen fish
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get
Unreachable catch block for FileNotFoundException. This exception is never thrown from the try statement body

when I do

try {
_help= new HelpMethod();
}catch(FileNotFoundException e){

}

It's try to create a log when I'm making HelpMethod, but I dont want the log to be made and I can't change the HelpMethod Class.
Any suggestion will be great,

Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!