<<< multi-catch block, cont. | Index | Throwing and re-throwing an exception >>> |
Programming style using the 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 | EOFException ex ) { System.err.println( ex.toString() ); return null; } catch( IOException ex ) { ex.printStackTrace(); return null; } }
<<< multi-catch block, cont. | Index | Throwing and re-throwing an exception >>> |