Multiple catch in Java 7

It's a new flavor of multiple exception hadler catch....

Before Java 7:


try {

// Some code here to access any file like reading/writing....

} catch (FileNotFoundException e) {
    System.err.println("FileNotFoundException: "
                        + e.getMessage());
    throw new SampleException(e);

} catch (IOException e) {
    System.err.println("Caught IOException: "
                        + e.getMessage());
}

Now in java 7:

try {

// Some code here to access any file like reading/writing....

} 
catch (FileNotFoundException |IOException ex) {
    logger.log(ex);
    
}

Comments

Popular posts from this blog

Read Images from a xlsx file using Apache POI

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

How to create mail message in FRC822 format