@Test public void testReadLineWithChop() { ByteLineReader br = new ByteLineReader(lines); byte[] line; line = br.readLine(true); assertTrue(bytesMatchString("", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("abc", line)); line = br.readLine(true); assertTrue(bytesMatchString("", line)); line = br.readLine(true); assertTrue(bytesMatchString("x", line)); }
public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; }
ByteLineReader { public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; } }
ByteLineReader { public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; } ByteLineReader(byte[] bytes); }
ByteLineReader { public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; } ByteLineReader(byte[] bytes); int getBytesRead(); int bytesAvailable(); byte[] readLine(boolean chop); byte[] readLine(); static boolean cmpBytes(byte[] a, byte[] b); static byte[] appendLF(byte[] bytesIn); static byte[] copyBytes(byte[] inBytes); static byte[] chopLine(byte[] lineIn); static byte[] trim(byte[] lineIn); }
ByteLineReader { public byte[] readLine(boolean chop) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(PAGESIZE); while (inStream.available() > 0) { int ch = inStream.read(); if (ch < 0) { break; } if (ch == CR) { continue; } if (ch == LF) { if (chop) { break; } else { outStream.write(ch); break; } } outStream.write(ch); } byte[] line = outStream.toByteArray(); return line; } ByteLineReader(byte[] bytes); int getBytesRead(); int bytesAvailable(); byte[] readLine(boolean chop); byte[] readLine(); static boolean cmpBytes(byte[] a, byte[] b); static byte[] appendLF(byte[] bytesIn); static byte[] copyBytes(byte[] inBytes); static byte[] chopLine(byte[] lineIn); static byte[] trim(byte[] lineIn);  }