//this is code that doesn''t handle the exception, but passes it//to the calling method to handle.//Good if the exception means that program execution can''t continue//because something very screwed up has happenedtry { //call readLine, etc. Methods that throw IOException.} catch(IOException e) { throw e;} //This code just prints the stack trace (poor example of handling the exception).//You handle the exception, and don''t rethrow it if you think that the exception is trivial and can be handled locally.//you want program execution to continue.try { //call readLine, etc. Methods that throw IOException.} catch(IOException e) { e.printStackTrace();}
That''s just my take. It probably isn''t best practice, but i can''t really see how else handle IOExceptions. IO is IMHO one of Java''s weakest points, thanks to its over use of checked exceptions.
Don''t know why it appeared on another thread..