<<< multi-catch block | Index | multi-catch block, cont >>> |
Programming style that does not employ a multi-catch block:
public static String readFirstLine( String path ) { try ( RandomAccessFile in = new RandomAccessFile( path, "r" ) ) { String line = in.readLine(); // may throw // IOException return line; } catch ( FileNotFoundException ex ) { System.err.println( ex.toString() ); return null; } catch ( EOFException ex ) { System.err.println( ex.toString() ); return null; } catch( IOException ex ) { ex.printStackTrace(); return null; } }
<<< multi-catch block | Index | multi-catch block, cont >>> |