List of utility methods to do ByteBuffer Clone
ByteBuffer | clone(ByteBuffer original) clone ByteBuffer clone = ByteBuffer.allocate(original.capacity());
original.rewind();
clone.put(original);
original.rewind();
clone.flip();
return clone;
|
ByteBuffer | clone(final ByteBuffer buf) clone if (buf == null) { return null; buf.rewind(); final ByteBuffer copy; if (buf.isDirect()) { copy = createByteBuffer(buf.limit()); } else { ... |
ByteBuffer | clone(final ByteBuffer original) Clones a bytebuffer final ByteBuffer clone = (original.isDirect()) ? ByteBuffer.allocateDirect(original.capacity()) : ByteBuffer.allocate(original.capacity()); final ByteBuffer readOnlyCopy = original.asReadOnlyBuffer(); clone.put(readOnlyCopy); return clone; |
ByteBuffer | cloneAsDirectByteBuffer(byte[] input, int offset, int len) Clone an input bytes array as direct ByteBuffer. if (input == null) { return null; ByteBuffer directBuffer = ByteBuffer.allocateDirect(len); directBuffer.put(input, offset, len); directBuffer.flip(); return directBuffer; |
ByteBuffer | cloneBuffer(ByteBuffer pesBuffer) clone Buffer ByteBuffer res = ByteBuffer.allocate(pesBuffer.remaining());
res.put(pesBuffer.duplicate());
res.clear();
return res;
|
ByteBuffer | cloneBufferData(ByteBuffer srcBuffer) clone Buffer Data ByteBuffer destBuffer; byte[] bytesArr = new byte[srcBuffer.remaining()]; srcBuffer.mark(); srcBuffer.get(bytesArr); srcBuffer.reset(); if (!srcBuffer.isDirect()) { destBuffer = ByteBuffer.wrap(bytesArr); } else { ... |
ByteBuffer | cloneByteBuffer(ByteBuffer buf) clone Byte Buffer ByteBuffer ret = ByteBuffer.allocate(buf.limit() - buf.position());
ret.put(buf);
ret.flip();
buf.flip();
return ret;
|
ByteBuffer | cloneByteBuffer(ByteBuffer buf) Clones a ByteBuffer . ByteBuffer ret = ByteBuffer.allocate(buf.limit() - buf.position()); if (buf.hasArray()) { ret.put(buf.array(), buf.position(), buf.limit() - buf.position()); } else { ret.put(buf); ret.flip(); return ret; ... |
List | cloneByteBufferList(List clone Byte Buffer List List<ByteBuffer> ret = new ArrayList<ByteBuffer>(source.size()); for (int k = 0; k < source.size(); k++) { ret.add(cloneByteBuffer(source.get(k))); return ret; |
List | cloneByteBufferList(List Clones a list of ByteBuffer s. List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); return ret; |