public class ExceptionExample {
    
    public static void main(String[] args) {
        Scanner scanner = null;
        try {            
            scanner = new Scanner(new File("data2.txt"));
                       
            System.out.println(scanner.nextLine());            
        }catch (FileNotFoundException|IllegalStateException e) {  
            System.out.println("You're doing it wrong, mate!");
            return;
        }catch (IOException e) {
            System.out.println("Something went wrong while handling the file. Stack trace can be seen below");
            e.printStackTrace();
        }finally {
            System.out.println("Hello finally code");
            if (scanner != null) {
                System.out.println("Closing the scanner...");
                scanner.close();
            }
        }
    }
}