public static void main(String args[]) {
try{
FileInputStream fstream = ...
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
This try/catch is absolutely NOT NEEDED! If you skip them, the JVM does absolutely the same work. :)
Reply
daily quotes
Programming is not a zero-sum game. Teaching something to a fellow programmer doesn't take it away from you. I'm happy to share what I can, because I'm in it for the love of programming.
try/catch in main
One of my favorite examples is the main method with try/catch.
For example:
http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
public static void main(String args[]) {
try{
FileInputStream fstream = ...
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
This try/catch is absolutely NOT NEEDED! If you skip them, the JVM does absolutely the same work. :)