title: Why do I need to catch a close() exception in BufferedReader but not in PrintWriter?
body: <p>I have a simple file read and write function.</p>
  
  <pre><code>private void WriteToFile(String filename, String val) {
      PrintWriter outStream = null;
      FileOutputStream fos = null;
      try {
          fos = new FileOutputStream(filename);
          outStream = new PrintWriter(new OutputStreamWriter(fos));
          outStream.print(val);
          outStream.close();
      } catch (Exception e) {
          if (outStream != null) {
              outStream.close();
          }
      }
  }
  
  private String ReadFile(String filename) {
      String output = "";
      FileReader fr = null;
      BufferedReader br = null;
      try {
          fr = new FileReader(filename);
          br = new BufferedReader(fr);
          output = br.readLine();
          br.close();
      } catch (Exception e) {
          if (br != null) {
              br.close();
          }
      }
  
      return output;
  }
  </code></pre>
  
  <p>When building I get:</p>
  
  <pre><code>unreported exception java.io.IOException; must be caught or declared to be thrown
              br.close();
                      ^
  </code></pre>
  
  <p>Why do I need to catch br.close but it doesn't complain about WriteToFile's close()?</p>