title: Close resource quietly using try-with-resources
body: <p>Is it possible to ignore the exception thrown when a resource is closed using a try-with-resources statement?</p>
  
  <p>Example:</p>
  
  <pre><code>class MyResource implements AutoCloseable{
    @Override
    public void close() throws Exception {
      throw new Exception("Could not close");
    }  
    public void read() throws Exception{      
    }
  }
  
  //this method prints an exception "Could not close"
  //I want to ignore it
  public static void test(){
    try(MyResource r = new MyResource()){
      r.read();
    } catch (Exception e) {
      System.out.println("Exception: " + e.getMessage());
    }
  }
  </code></pre>
  
  <p>Or should I continue to close in a <code>finally</code> instead?</p>
  
  <pre><code>public static void test2(){
    MyResource r = null;
    try {
       r.read();
    }
    finally{
      if(r!=null){
        try {
          r.close();
        } catch (Exception ignore) {
        }
      }
    }
  }
  </code></pre>