title: java.io.FileNotFoundException (Too many open files)
body: <p>I use the following code to write some data to files:</p>
  
  <pre><code>BufferedWriter writer = null;
  try {
      writer = new BufferedWriter(new FileWriter(file));
      writer.write(...);
      writer.flush();
  }
  finally {
      if (writer != null)
          writer.close();
  }
  </code></pre>
  
  <p>After invoking the method multiple times I got a FileNotFoundException because too many files are open.</p>
  
  <p>Obviously java does not close the file handles when I close the writer stream. Closing the FileWriter separately does not help.</p>
  
  <p>Is there sth. I can do to force java to close the files?</p>