ReaderSerializer implements Serializer<Reader> { public void serialize(Reader value, Charset charset, OutputStream out) throws IOException { Writer w = new OutputStreamWriter(out, charset); IOs.copy(value, w, true); w.flush(); }  void serialize(Reader value, Charset charset, OutputStream out);  }
@Test public void shouldDumpReaderContentIntoOutputStream() throws IOException { TestReader in = new TestReader(new StringReader(SOME_STRING)); ByteArrayOutputStream out = new ByteArrayOutputStream(); toTest.serialize(in, UTF8, out); assertEquals(SOME_STRING, new String(out.toByteArray(), UTF8)); assertTrue(in.hasBeenClosed()); }