Catching multiple exception types to improve type checking - Java Language Basics

Java examples for Language Basics:try catch finally

Description

Catching multiple exception types to improve type checking

Demo Code

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) {
        try {/*from   ww  w.ja  va2 s  .  co m*/
            Files.delete(Paths.get(new URI("file:///tmp.txt")));
        } catch (URISyntaxException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

Related Tutorials