PlainTextByLineStream implements ObjectStream<String> { public String read() throws IOException { return in.readLine(); } PlainTextByLineStream(Reader in);  PlainTextByLineStream(InputStream in, String charsetName);  PlainTextByLineStream(InputStream in, Charset charset);  PlainTextByLineStream(FileChannel channel, String charsetName);  PlainTextByLineStream(FileChannel channel, Charset encoding); String read(); void reset(); void close();  }
@Test public void testLineSegmentation() throws IOException { StringBuilder testString = new StringBuilder(); testString.append("line1"); testString.append('\n'); testString.append("line2"); testString.append('\n'); testString.append("line3"); testString.append("\r\n"); testString.append("line4"); testString.append('\n'); ObjectStream<String> stream = new PlainTextByLineStream(new StringReader(testString.toString())); assertEquals("line1", stream.read()); assertEquals("line2", stream.read()); assertEquals("line3", stream.read()); assertEquals("line4", stream.read()); }