@Override public int read(final byte[] bytes, final int off, final int len) throws IOException { final byte[] chunk = new byte[len]; final int read = buffer.read(chunk, offset); if(read > 0) { offset += read; System.arraycopy(chunk, 0, bytes, off, read); } return read; } }
@Override public void flush() throws IOException { if(log.isDebugEnabled()) { log.debug(String.format("Copy buffer %s to output %s", buffer, proxy)); } IOUtils.copy(new BufferInputStream(buffer), proxy); // Re-use buffer buffer.truncate(0L); } }
@Override public void close() throws IOException { super.close(); buffer.close(); }
@Override public void write(final byte[] bytes, final int off, final int len) throws IOException { if(log.isLoggable(Level.FINE)) { log.fine(String.format("Buffer %d bytes at offset %d", len, offset)); } final byte[] chunk = new byte[len]; System.arraycopy(bytes, off, chunk, 0, len); buffer.write(chunk, offset); super.write(bytes, off, len); }