### Question:
ByteBufferUtils { public static void copyFromBufferToBuffer(ByteBuffer out, ByteBuffer in, int sourceOffset, int length) { if (in.hasArray() && out.hasArray()) { System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(), out.position() + out.arrayOffset(), length); skip(out, length); } else { for (int i = 0; i < length; ++i) { out.put(in.get(sourceOffset + i)); } } } private  ByteBufferUtils(); static void writeVLong(ByteBuffer out, long i); static long readVLong(ByteBuffer in); static int putCompressedInt(OutputStream out, final int value); static void putInt(OutputStream out, final int value); static void moveBufferToStream(OutputStream out, ByteBuffer in,
      int length); static void copyBufferToStream(OutputStream out, ByteBuffer in,
      int offset, int length); static int putLong(OutputStream out, final long value,
      final int fitInBytes); static int longFitsIn(final long value); static int intFitsIn(final int value); static int readCompressedInt(InputStream input); static int readCompressedInt(ByteBuffer buffer); static long readLong(InputStream in, final int fitInBytes); static long readLong(ByteBuffer in, final int fitInBytes); static void ensureSpace(ByteBuffer out, int length); static void copyFromStreamToBuffer(ByteBuffer out,
      DataInputStream in, int length); static void copyFromBufferToBuffer(ByteBuffer out,
      ByteBuffer in, int sourceOffset, int length); static int findCommonPrefix(ByteBuffer buffer, int offsetLeft,
      int offsetRight, int limit); static int findCommonPrefix(
      byte[] left, int leftOffset, int leftLength,
      byte[] right, int rightOffset, int rightLength); static boolean arePartsEqual(ByteBuffer buffer,
      int offsetLeft, int lengthLeft,
      int offsetRight, int lengthRight); static void skip(ByteBuffer buffer, int length);  }### Answer:
@Test public void testCopyFromBuffer() { ByteBuffer srcBuffer = ByteBuffer.allocate(array.length); ByteBuffer dstBuffer = ByteBuffer.allocate(array.length); srcBuffer.put(array); ByteBufferUtils.copyFromBufferToBuffer(dstBuffer, srcBuffer, array.length / 2, array.length / 4); for (int i = 0; i < array.length / 4; ++i) { assertEquals(srcBuffer.get(i + array.length / 2), dstBuffer.get(i)); } }