List of utility methods to do ByteBuffer Create
ByteBuffer | createByteBuffer(int size) create Byte Buffer totalsize += size;
return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
ByteBuffer | createByteBuffer(int size) Create a direct byte buffer with the given size return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
|
ByteBuffer | createByteBufferOnHeap(int size) Create a new ByteBuffer of the specified size. ByteBuffer buf = ByteBuffer.allocate(size).order(ByteOrder.nativeOrder());
buf.clear();
return buf;
|
ByteBuffer | createCopy(ByteBuffer buffer) create Copy buffer.rewind();
ByteBuffer copy = ByteBuffer.allocate(buffer.limit());
copy.order(buffer.order());
copy.put(buffer);
return copy;
|
java.nio.ByteBuffer | createDirectByteBuffer(byte[] data) create Direct Byte Buffer if (data == null) { return null; java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocateDirect((Byte.SIZE / 8) * data.length) .order(java.nio.ByteOrder.nativeOrder()); buf.clear(); buf.put(data); buf.flip(); ... |
ByteBuffer[] | createIconsFromBuffers(List create Icons From Buffers ByteBuffer[] icons = new ByteBuffer[byteBuffers.size()]; for (int i = 0; i < byteBuffers.size(); i++) { icons[i] = byteBuffers.get(i); return icons; |
InputStream | createInputStream(final ByteBuffer buf) create Input Stream return new InputStream() { @Override public int read() throws IOException { if (!buf.hasRemaining()) { return -1; return buf.get() & 0xFF; @Override public int read(byte[] bytes, int off, int len) throws IOException { if (!buf.hasRemaining()) { return -1; len = Math.min(len, buf.remaining()); buf.get(bytes, off, len); return len; }; |
byte[] | newByteArrayFromByteBuffer(ByteBuffer buf) Creates a byte array from the given ByteBuffer, the position property of input ByteBuffer remains unchanged. final int length = buf.remaining(); byte[] bytes = new byte[length]; buf.duplicate().get(bytes, 0, length); return bytes; |
ByteBuffer | newByteBuffer(int bufferSize, boolean direct) new Byte Buffer if (direct) { return ByteBuffer.allocateDirect(bufferSize); } else { return ByteBuffer.allocate(bufferSize); |
ByteBuffer | newByteBuffer(int len) new Byte Buffer return ByteBuffer.allocateDirect(len).order(ByteOrder.nativeOrder());
|