@Test public void readWithLargeCharBuffer() throws IOException { final CharBuffer buffer = CharBuffer.allocate(20); assertEquals(DEFAULT_TOTAL, cut.read(buffer)); buffer.flip(); assertEquals(DEFAULT_COMBINED, buffer.toString()); }
@Override public int read(CharBuffer target) throws IOException { int len = target.remaining(); int remainingInPrefix = prefix.length - prefixLocation; if (remainingInPrefix >= len) { target.put(prefix, prefixLocation, len); prefixLocation += len; return len; } if (remainingInPrefix > 0) { target.put(prefix, prefixLocation, remainingInPrefix); prefixLocation = prefix.length; } int readFromDelegate = delegate.read(target); if (remainingInPrefix > 0 && readFromDelegate < 0) { return remainingInPrefix; } return remainingInPrefix + readFromDelegate; }
PrefixReader extends Reader { @Override public int read(CharBuffer target) throws IOException { int len = target.remaining(); int remainingInPrefix = prefix.length - prefixLocation; if (remainingInPrefix >= len) { target.put(prefix, prefixLocation, len); prefixLocation += len; return len; } if (remainingInPrefix > 0) { target.put(prefix, prefixLocation, remainingInPrefix); prefixLocation = prefix.length; } int readFromDelegate = delegate.read(target); if (remainingInPrefix > 0 && readFromDelegate < 0) { return remainingInPrefix; } return remainingInPrefix + readFromDelegate; } }
PrefixReader extends Reader { @Override public int read(CharBuffer target) throws IOException { int len = target.remaining(); int remainingInPrefix = prefix.length - prefixLocation; if (remainingInPrefix >= len) { target.put(prefix, prefixLocation, len); prefixLocation += len; return len; } if (remainingInPrefix > 0) { target.put(prefix, prefixLocation, remainingInPrefix); prefixLocation = prefix.length; } int readFromDelegate = delegate.read(target); if (remainingInPrefix > 0 && readFromDelegate < 0) { return remainingInPrefix; } return remainingInPrefix + readFromDelegate; } PrefixReader(char[] prefix, Reader delegate);  PrefixReader(Object lock, char[] prefix, Reader delegate); }
PrefixReader extends Reader { @Override public int read(CharBuffer target) throws IOException { int len = target.remaining(); int remainingInPrefix = prefix.length - prefixLocation; if (remainingInPrefix >= len) { target.put(prefix, prefixLocation, len); prefixLocation += len; return len; } if (remainingInPrefix > 0) { target.put(prefix, prefixLocation, remainingInPrefix); prefixLocation = prefix.length; } int readFromDelegate = delegate.read(target); if (remainingInPrefix > 0 && readFromDelegate < 0) { return remainingInPrefix; } return remainingInPrefix + readFromDelegate; } PrefixReader(char[] prefix, Reader delegate);  PrefixReader(Object lock, char[] prefix, Reader delegate); @Override int read(CharBuffer target); @Override int read(); @Override int read(char[] cbuf, int off, int len); @Override long skip(long n); @Override boolean ready(); @Override boolean markSupported(); @Override void mark(int readAheadLimit); @Override void reset(); @Override void close(); }
PrefixReader extends Reader { @Override public int read(CharBuffer target) throws IOException { int len = target.remaining(); int remainingInPrefix = prefix.length - prefixLocation; if (remainingInPrefix >= len) { target.put(prefix, prefixLocation, len); prefixLocation += len; return len; } if (remainingInPrefix > 0) { target.put(prefix, prefixLocation, remainingInPrefix); prefixLocation = prefix.length; } int readFromDelegate = delegate.read(target); if (remainingInPrefix > 0 && readFromDelegate < 0) { return remainingInPrefix; } return remainingInPrefix + readFromDelegate; } PrefixReader(char[] prefix, Reader delegate);  PrefixReader(Object lock, char[] prefix, Reader delegate); @Override int read(CharBuffer target); @Override int read(); @Override int read(char[] cbuf, int off, int len); @Override long skip(long n); @Override boolean ready(); @Override boolean markSupported(); @Override void mark(int readAheadLimit); @Override void reset(); @Override void close();  }