@Test public void testCopyToAdvancesPositionOnlyInDest() { ByteBuffer src = ByteBuffer.allocate(10); ByteBuffer dest = ByteBuffer.allocate(10); ByteBuffers.copyTo(src, dest); assertEquals(0, src.position()); assertEquals(10, dest.position()); }
public static void copyTo(ByteBuffer src, ByteBuffer dest) { if (src == null || dest == null) { return; } if (src.hasArray()) { byte[] array = src.array(); int offset = src.arrayOffset() + src.position(); int length = src.remaining(); dest.put(array, offset, length); } else { for (int i = src.position(); i < src.limit(); i++) { dest.put(src.get(i)); } } }
ByteBuffers { public static void copyTo(ByteBuffer src, ByteBuffer dest) { if (src == null || dest == null) { return; } if (src.hasArray()) { byte[] array = src.array(); int offset = src.arrayOffset() + src.position(); int length = src.remaining(); dest.put(array, offset, length); } else { for (int i = src.position(); i < src.limit(); i++) { dest.put(src.get(i)); } } } }
ByteBuffers { public static void copyTo(ByteBuffer src, ByteBuffer dest) { if (src == null || dest == null) { return; } if (src.hasArray()) { byte[] array = src.array(); int offset = src.arrayOffset() + src.position(); int length = src.remaining(); dest.put(array, offset, length); } else { for (int i = src.position(); i < src.limit(); i++) { dest.put(src.get(i)); } } }  }
ByteBuffers { public static void copyTo(ByteBuffer src, ByteBuffer dest) { if (src == null || dest == null) { return; } if (src.hasArray()) { byte[] array = src.array(); int offset = src.arrayOffset() + src.position(); int length = src.remaining(); dest.put(array, offset, length); } else { for (int i = src.position(); i < src.limit(); i++) { dest.put(src.get(i)); } } }  static void copyTo(ByteBuffer src, ByteBuffer dest); static ByteBuffer copyWithPrefix(byte prefix, ByteBuffer src); static ByteBuffer copyRemaining(ByteBuffer src); static byte[] copyRemainingBytes(ByteBuffer src); static String getString(ByteBuffer buf); }
ByteBuffers { public static void copyTo(ByteBuffer src, ByteBuffer dest) { if (src == null || dest == null) { return; } if (src.hasArray()) { byte[] array = src.array(); int offset = src.arrayOffset() + src.position(); int length = src.remaining(); dest.put(array, offset, length); } else { for (int i = src.position(); i < src.limit(); i++) { dest.put(src.get(i)); } } }  static void copyTo(ByteBuffer src, ByteBuffer dest); static ByteBuffer copyWithPrefix(byte prefix, ByteBuffer src); static ByteBuffer copyRemaining(ByteBuffer src); static byte[] copyRemainingBytes(ByteBuffer src); static String getString(ByteBuffer buf); static final Comparator<ByteBuffer> LEXICOGRAPHIC_COMPARATOR; }