title: Interlacing BufferedWriter and PrintWriter
body: <p>Is it safe to interlace <code>BufferedWriter</code> and <code>PrintWriter</code> in Java? Consider the following example:</p>
  
  <pre><code>private void writeToFile(File file, String text, Throwable throwable) throws Exception { // I use the "throws Exception" here for simplicity of the example
      // Write text
      BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
      bufferedWriter.write(text);
      bufferedWriter.newLine();
      bufferedWriter.flush();
  
      // Write StackTrace
      PrintWriter printWriter = new PrintWriter(bufferedWriter);
      throwable.printStackTrace(printWriter);
      printWriter.close();
  }
  </code></pre>
  
  <p>I know I could use the <code>PrintWriter</code> to write the text as well. But my questions are:</p>
  
  <ul>
  <li>Is it safe to use a <code>PrintWriter</code> and the <code>BufferedWriter</code> this way?</li>
  <li>If it is safe, would it also be safe without the <code>bufferedWriter.flush()</code>?</li>
  <li>If it is safe, would it also be safe to use the <code>BufferedWriter</code> again, after I used the <code>PrintWriter</code>?</li>
  </ul>
  
  <p>Note that the similar question <a href="https://stackoverflow.com/questions/15803350/filewrite-bufferedwriter-and-printwriter-combined">here</a> assumes that only the <code>PrintWriter</code> is accessed, and therefore doesn't answer my question.</p>