Monday 15 March 2010

java - Translating what an exception catches -



java - Translating what an exception catches -

i have code snippet working on:

public void readfile() { bufferedreader reader = null; bufferedreader reader2 = null; seek { reader = new bufferedreader(new filereader("c:/users/user/desktop/testing.txt")); reader2 = new bufferedreader(new filereader("c:/users/user/desktop/testnotthere.txt")); } grab (filenotfoundexception e) { system.err.println("error: file not found!\n"); } string line = null; seek { while ((line = reader.readline()) != null) { system.out.print(line); } } grab (ioexception e) { e.printstacktrace(); } }

and while understand first exception snippet detects: catch (filenotfoundexception e), looking understand sec exception looking while printing lines of text file:

catch (ioexception e) { e.printstacktrace(); }

can explain sec exception looking for? furthermore, how can test create sure exception thrown in snippet did creating sec bufferedreader reader2?

ioexception thrown when programme interrupted while reading file. may see, io stands "input/output" means reading , writing info on disk. exception of kind means scheme crashed while while doing reading/writing.

source: http://docs.oracle.com/javase/7/docs/api/java/io/ioexception.html

java try-catch

No comments:

Post a Comment