Here you can find the source of copy(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | a parameter |
private static final byte[] copy(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**// ww w . ja v a 2 s .co m * Copy binary * @param bytes * @return */ private static final byte[] copy(byte[] bytes) { byte[] copy = new byte[bytes.length]; System.arraycopy(bytes, 0, copy, 0, bytes.length); return copy; } /** * Copy buffer to byte array * @param buffer * @return */ private static final byte[] copy(ByteBuffer buffer) { buffer.mark(); byte[] bytes = new byte[buffer.limit()]; buffer.get(bytes); buffer.reset(); return bytes; } }