public ByteBuffersDataInput slice(long offset, long length) { if (offset < 0 || length < 0 || offset + length > this.size) { throw new IllegalArgumentException(String.format(Locale.ROOT, "slice(offset=%s, length=%s) is out of bounds: %s", offset, length, this)); } return new ByteBuffersDataInput(sliceBufferList(Arrays.asList(this.blocks), offset, length)); }
/** * Return a {@link ByteBuffersDataInput} for the set of current buffers ({@link #toBufferList()}). */ public ByteBuffersDataInput toDataInput() { return new ByteBuffersDataInput(toBufferList()); }
/** * Copy the current content of this object into another {@link DataOutput}. */ public void copyTo(DataOutput output) throws IOException { for (ByteBuffer bb : toBufferList()) { if (bb.hasArray()) { output.writeBytes(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining()); } else { output.copyBytes(new ByteBuffersDataInput(Arrays.asList(bb)), bb.remaining()); } } }
/** * Return a {@link ByteBuffersDataInput} for the set of current buffers ({@link #toBufferList()}). */ public ByteBuffersDataInput toDataInput() { return new ByteBuffersDataInput(toBufferList()); }
public ByteBuffersDataInput slice(long offset, long length) { if (offset < 0 || length < 0 || offset + length > this.size) { throw new IllegalArgumentException(String.format(Locale.ROOT, "slice(offset=%s, length=%s) is out of bounds: %s", offset, length, this)); } return new ByteBuffersDataInput(sliceBufferList(Arrays.asList(this.blocks), offset, length)); }
/** * Copy the current content of this object into another {@link DataOutput}. */ public void copyTo(DataOutput output) throws IOException { for (ByteBuffer bb : toBufferList()) { if (bb.hasArray()) { output.writeBytes(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining()); } else { output.copyBytes(new ByteBuffersDataInput(Arrays.asList(bb)), bb.remaining()); } } }