title: Is there a way to close a Writer without closing the underlying stream?
body: <p>I have a socket to which I write some character data, and some raw byte data. For the character data, it's easier to use a <code>PrintWriter</code>. For the raw byte data, it's easier to write directly to the <code>OutputStream</code>. So throughout my code, I have segments like this:</p>
  
  <pre><code>Writer writer = new PrintWriter(outputStream);
  writer.write(someText);
  ...
  writer.flush();
  // No call to writer.close(), because that would close the underlying stream.
  </code></pre>
  
  <p>As long as I am careful not to write to this <code>Writer</code> after beginning to write to the stream in some other way, this is fine. But I would prefer the safety of knowing that I'll get an <code>IOException</code> if I accidentally do write to the stream (as I would if I had closed it).</p>
  
  <p>Is there a way to explicitly prevent future writes to a <code>Writer</code> without closing its underlying stream?</p>