Here you can find the source of copyToArray(@Nonnull ByteBuffer data)
public static byte[] copyToArray(@Nonnull ByteBuffer data)
//package com.java2s; //License from project: Open Source License import javax.annotation.Nonnull; import java.nio.ByteBuffer; public class Main { public static byte[] copyToArray(@Nonnull ByteBuffer data) { byte[] copy = new byte[data.remaining()]; data.duplicate().get(copy);/* w ww .j a v a 2s .c om*/ return copy; } }