title: After closing stdout: Java silently swallows everything written to stdout
body: <p>Have a look at this example:</p>
  
  <pre><code>import java.io.FileDescriptor;
  import java.io.FileOutputStream;
  import java.io.IOException;
  
  public class Main {
  
    public static void main(String[] args) {
      System.out.println("hi there!");
      System.out.close();
      System.out.println("I'm silently swallowed :(");
      System.out.flush(); // even flushing and closing again
      System.out.close(); // doesn't throw an Exception
      try {
        FileOutputStream fos = new FileOutputStream(FileDescriptor.out);
        fos.flush(); // same goes for this more direct approach
        fos.close();
      } catch (IOException e) {
        e.printStackTrace(System.err);
      }
    }
  }
  </code></pre>
  
  <p>Why doesn't the JVM tell me somehow, that writing to stdout failed? I would expect to get an Exception <em>somewhere</em>.</p>
  
  <p>How else could I detect such a situation?</p>