@Test public void shouldReadRemainder() throws IOException { reader = newReaderInstance(EXAMPLE_INPUT_STRING, DEFAULT_BUFFER_SIZE); char[] buffer = new char[5]; reader.read(buffer); assertThat(SpinIoUtil.getStringFromReader(reader)).isEqualTo(EXAMPLE_INPUT_STRING.substring(5)); }
public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.length - pos; int insertableCharacters = Math.min(charactersRead, freeBufferSpace); System.arraycopy(cbuf, off, buffer, pos, insertableCharacters); pos += insertableCharacters; } } return charactersRead; }
RewindableReader extends Reader { public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.length - pos; int insertableCharacters = Math.min(charactersRead, freeBufferSpace); System.arraycopy(cbuf, off, buffer, pos, insertableCharacters); pos += insertableCharacters; } } return charactersRead; } }
RewindableReader extends Reader { public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.length - pos; int insertableCharacters = Math.min(charactersRead, freeBufferSpace); System.arraycopy(cbuf, off, buffer, pos, insertableCharacters); pos += insertableCharacters; } } return charactersRead; } RewindableReader(Reader input, int size); }
RewindableReader extends Reader { public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.length - pos; int insertableCharacters = Math.min(charactersRead, freeBufferSpace); System.arraycopy(cbuf, off, buffer, pos, insertableCharacters); pos += insertableCharacters; } } return charactersRead; } RewindableReader(Reader input, int size); int read(char[] cbuf, int off, int len); int read(); void close(); synchronized void mark(int readlimit); boolean markSupported(); synchronized void reset(); long skip(long n); void rewind(); int getRewindBufferSize(); int getCurrentRewindableCapacity(); }
RewindableReader extends Reader { public int read(char[] cbuf, int off, int len) throws IOException { int charactersRead = wrappedReader.read(cbuf, off, len); if (charactersRead > 0) { if (rewindable && pos + charactersRead > buffer.length) { rewindable = false; } if (pos < buffer.length) { int freeBufferSpace = buffer.length - pos; int insertableCharacters = Math.min(charactersRead, freeBufferSpace); System.arraycopy(cbuf, off, buffer, pos, insertableCharacters); pos += insertableCharacters; } } return charactersRead; } RewindableReader(Reader input, int size); int read(char[] cbuf, int off, int len); int read(); void close(); synchronized void mark(int readlimit); boolean markSupported(); synchronized void reset(); long skip(long n); void rewind(); int getRewindBufferSize(); int getCurrentRewindableCapacity();  }