@Test public void cloneByteBufferList() { final int bufferSize = 10; final int listLength = 10; ArrayList<ByteBuffer> bufList = new ArrayList<>(listLength); for (int k = 0; k < listLength; k++) { ByteBuffer buf = ByteBuffer.allocate(bufferSize); for (byte i = 0; i < bufferSize; i++) { buf.put((byte) (i + k)); } bufList.add(buf); } List<ByteBuffer> bufListClone = BufferUtils.cloneByteBufferList(bufList); assertEquals(listLength, bufListClone.size()); for (int k = 0; k < listLength; k++) { assertEquals(bufList.get(k), bufListClone.get(k)); } }
public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); } return ret; }
BufferUtils { public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); } return ret; } }
BufferUtils { public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); } return ret; } private  BufferUtils(); }
BufferUtils { public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); } return ret; } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position); }
BufferUtils { public static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source) { List<ByteBuffer> ret = new ArrayList<>(source.size()); for (ByteBuffer b : source) { ret.add(cloneByteBuffer(b)); } return ret; } private  BufferUtils(); static int byteToInt(byte b); static synchronized void cleanDirectBuffer(ByteBuffer buffer); static ByteBuffer cloneByteBuffer(ByteBuffer buf); static List<ByteBuffer> cloneByteBufferList(List<ByteBuffer> source); static void putIntByteBuffer(ByteBuffer buf, int b); static byte[] getIncreasingByteArray(int len); static byte[] getIncreasingByteArray(int start, int len); static boolean equalConstantByteArray(byte value, int len, byte[] arr); static boolean equalIncreasingByteArray(int len, byte[] arr); static boolean equalIncreasingByteArray(int start, int len, byte[] arr); static ByteBuffer getIncreasingByteBuffer(int len); static ByteBuffer getIncreasingByteBuffer(int start, int len); static boolean equalIncreasingByteBuffer(int start, int len, ByteBuffer buf); static void writeBufferToFile(String path, byte[] buffer); static void fastCopy(final ReadableByteChannel src, final WritableByteChannel dest); static int intAsUnsignedByteValue(int i); static byte[] newByteArrayFromByteBuffer(ByteBuffer buf); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position, int length); static ByteBuffer sliceByteBuffer(ByteBuffer buffer, int position);  }