Here you can find the source of toArray(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | The buffer to read from. |
public static byte[] toArray(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**// w w w. j a va 2 s . c om * @param buffer The buffer to read from. * @return Returns the remaining bytes from the buffer copied to an array. */ public static byte[] toArray(ByteBuffer buffer) { byte[] dst = new byte[buffer.remaining()]; buffer.mark(); buffer.get(dst); buffer.reset(); return dst; } }