WriterOutputStream extends OutputStream { @Override public void flush() throws IOException { _flushBuffer(); _writer.flush(); } WriterOutputStream(Writer writer);  WriterOutputStream(Writer writer, String charsetName);  WriterOutputStream(
		Writer writer, String charsetName, boolean autoFlush);  WriterOutputStream(
		Writer writer, String charsetName, int outputBufferSize);  WriterOutputStream(
		Writer writer, String charsetName, int outputBufferSize,
		boolean autoFlush); @Override void close(); @Override void flush(); String getEncoding(); @Override void write(byte[] bytes); @Override void write(byte[] bytes, int offset, int length); @Override void write(int b);  }
@Test public void testFlush() throws IOException { final AtomicBoolean flushed = new AtomicBoolean(); CharArrayWriter charArrayWriter = new CharArrayWriter() { @Override public void flush() { flushed.set(true); } }; WriterOutputStream writerOutputStream = new WriterOutputStream( charArrayWriter, StringPool.UTF8, 2); Assert.assertFalse(flushed.get()); writerOutputStream.write('a'); Assert.assertFalse(flushed.get()); Assert.assertEquals(0, charArrayWriter.size()); writerOutputStream.write('b'); Assert.assertFalse(flushed.get()); Assert.assertEquals(0, charArrayWriter.size()); writerOutputStream.write('c'); Assert.assertFalse(flushed.get()); Assert.assertEquals("ab", charArrayWriter.toString()); writerOutputStream.write('d'); Assert.assertFalse(flushed.get()); Assert.assertEquals("ab", charArrayWriter.toString()); writerOutputStream.flush(); Assert.assertTrue(flushed.get()); Assert.assertEquals("abcd", charArrayWriter.toString()); }