Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Sheriffs:
Rob Spoor
Junilu Lacar
paul wheaton
Saloon Keepers:
Stephan van Hulst
Tim Moores
Tim Holloway
Carey Brown
Scott Selikoff
Bartenders:
Piet Souris
Jj Roberts
fred rosenberger
Forum:
Programmer Certification (OCPJP)
problem with catch and finally
Angela lewis
Ranch Hand
Posts: 100
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; } catch(IOException ioe) { } finally{ System.out.println("Doing finally"); } return 0; } }
If Hello.txt does not exist then the output would be
No such file found
Doing finally
-1
Why isn't it
No such file found
Doing finally
-1
Thanks
Swamy Nathan
Ranch Hand
Posts: 187
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Something seems to be wrong with the question (I think)?
Looluo Zhu
Greenhorn
Posts: 8
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think the question should be
No such file found
Doing finally
0
Why isn't it
No such file found
Doing finally
-1
and
this thread
has the answer.
SCJP 1.4
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Exceptions
exCeption
try catch block
Doubt regarding FileInputStream
static methods
More...