Java Exception try-with-resources with your own resource

Description

Java Exception try-with-resources with your own resource

class MyResource implements AutoCloseable {
  public void close() {
    System.out.println("In MyResource?s close()");
  }/*w ww  . j  a v a2 s  .  c o  m*/
}

public class Main {
  public static void main(String args[]) throws Exception {
    try (MyResource mr = new MyResource()) {
      // ...
    } finally {
      System.out.println("In finally");
    }
  }
}



PreviousNext

Related