public void testEofReadLine() throws Exception { writeToPipe("one line\ntwo lines\nthree lines"); output.close(); assertFalse(reader.isEof()); reader.readLine(); assertFalse(reader.isEof()); reader.readLine(); assertFalse(reader.isEof()); reader.readLine(); assertTrue(reader.isEof()); }
public void testEofReadUpTo() throws Exception { writeToPipe("mark one, mark two, the end"); output.close(); assertFalse(reader.isEof()); reader.readUpTo("one"); assertFalse(reader.isEof()); reader.readUpTo("two"); assertFalse(reader.isEof()); reader.readUpTo("three"); assertTrue(reader.isEof()); }
public void testEofReadCount() throws Exception { writeToPipe("abcdefghijklmnopqrstuvwxyz"); output.close(); assertFalse(reader.isEof()); reader.read(10); assertFalse(reader.isEof()); reader.read(16); assertFalse(reader.isEof()); reader.read(1); assertTrue(reader.isEof()); }
public static void copyBytes(InputStream input, OutputStream output) throws Exception { StreamReader reader = new StreamReader(input); while (!reader.isEof()) output.write(reader.readBytes(1000)); }