List of utility methods to do ByteBuffer Copy
void | copy(ByteBuffer src, ByteBuffer dst, int length) copy int srcLimit = src.limit(); int dstLimit = dst.limit(); src.limit(src.position() + length); dst.limit(dst.position() + length); dst.put(src); src.limit(srcLimit); dst.limit(dstLimit); |
void | copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length) copy System.arraycopy(src.array(), srcStartindex, dest.array(), destStartIndex, length); |
ByteBuffer | copy(ByteBuffer src, int startindex, int endindex) copy int size = endindex - startindex; ByteBuffer ret = ByteBuffer.allocate(size); src.position(startindex); for (int i = 0; i < size; i++) { ret.put(src.get()); return ret; |
int | copy(final ByteBuffer from, final ByteBuffer to) copy final int len = from.limit(); return copy(from, 0, to, 0, len); |
void | copy2Buffer(byte[] src, int srcOff, int srcLen, ByteBuffer dst, int dstOff) copy Buffer dst.reset(); dst.position(dst.position() + dstOff); dst.put(src, srcOff, srcLen); dst.reset(); |
ByteBuffer | copyBinary(final ByteBuffer orig) copy Binary if (orig == null) { return null; ByteBuffer copy = ByteBuffer.wrap(new byte[orig.remaining()]); if (orig.hasArray()) { System.arraycopy(orig.array(), orig.arrayOffset() + orig.position(), copy.array(), 0, orig.remaining()); } else { orig.slice().get(copy.array()); ... |
void | copyBuffer(ByteBuffer dest, int pos1, ByteBuffer src, int len) copy Buffer Objects.requireNonNull(dest); Objects.requireNonNull(src); if (pos1 >= 0 && len >= 0) { for (int i = 0; i < len && src.hasRemaining(); ++i) dest.put(pos1 + i, src.get()); |
void | copyBufferToStream(OutputStream out, ByteBuffer in, int offset, int length) Copy data from a buffer to an output stream. if (in.hasArray()) { out.write(in.array(), in.arrayOffset() + offset, length); } else { for (int i = 0; i < length; ++i) { out.write(in.get(offset + i)); |
ByteBuffer | copyByteBuffer(ByteBuffer buf) copy Byte Buffer ByteBuffer dest = newByteBuffer(buf.remaining());
buf.mark();
dest.put(buf);
buf.reset();
dest.rewind();
return dest;
|
ByteBuffer | copyByteBuffer(ByteBuffer src) Make a copy of an existing buffer (src) to a new buffer (dest) ByteBuffer dest = newByteBuffer(src.capacity());
src.rewind();
dest.put(src);
return dest;
|