@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public long skip(long n) throws IOException { /* * This could be made more efficient by using position to skip within the current buffer. */ long skipped = 0; while (n > 0 && available() > 0) { this.read(); n--; skipped++; } return skipped; }
private void testIO_356(final int bufferSize, final int dataSize, final int readFirst, final String csName) throws Exception { final CharSequenceInputStream is = new CharSequenceInputStream(ALPHABET, csName, bufferSize); for (int i = 0; i < readFirst; i++) { final int ch = is.read(); assertFalse(ch == -1); } is.mark(dataSize); final byte[] data1 = new byte[dataSize]; final int readCount1 = is.read(data1); assertEquals(dataSize, readCount1); is.reset(); // should allow data to be re-read final byte[] data2 = new byte[dataSize]; final int readCount2 = is.read(data2); assertEquals(dataSize, readCount2); is.close(); // data buffers should be identical assertArrayEquals("bufferSize=" + bufferSize + " dataSize=" + dataSize, data1, data2); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }
@Override public long skip(long n) throws IOException { /* * This could be made more efficient by using position to skip within the current buffer. */ long skipped = 0; while (n > 0 && available() > 0) { this.read(); n--; skipped++; } return skipped; }
@Override public long skip(long n) throws IOException { /* * This could be made more efficient by using position to skip within the current buffer. */ long skipped = 0; while (n > 0 && available() > 0) { this.read(); n--; skipped++; } return skipped; }