title: Exception coming out of close() in try-with-resource
body: <p>I was reading about the try-with-resource in JDK7 and while I was thinking of upgrading my application to run with JDK7 I faced this problem..</p>
  
  <p>When using a BufferedReader for example the write throws IOException and the close throws IOException.. in the catch block I am concerned in the IOException thrown by the write.. but I wouldn't care much about the one thrown by the close.. </p>
  
  <p>Same problem with database connections.. and any other resource.. </p>
  
  <p>As an example I've created an auto closeable resource:</p>
  
  <pre><code>public class AutoCloseableExample implements AutoCloseable {
  
      public AutoCloseableExample() throws IOException{
          throw new IOException();
      }
  
      @Override
      public void close() throws IOException {
          throw new IOException("An Exception During Close");
      }
  
  }
  </code></pre>
  
  <p>Now when using it:</p>
  
  <pre><code>public class AutoCloseTest {
  
      public static void main(String[] args) throws Exception {
          try (AutoCloseableExample example = new AutoCloseableExample()) {
              System.out.println(example);
  
              throw new IOException("An Exception During Read");
          } catch (Exception x) {
              System.out.println(x.getMessage());
          } 
      }
  
  }
  </code></pre>
  
  <p>how can I distinguish between such exceptions without having to create wrappers for classes such as BufferedReader?</p>
  
  <p>Most of cases I put the resource close in a try/catch inside the finally block without caring much about handling it.</p>