Java examples for java.nio:ByteBuffer Convert
Convert remaining ByteBuffer to byte array.
/*//ww w. j a va 2 s . com * WireSpider * * Copyright (c) 2015 kazyx * * This software is released under the MIT License. * http://opensource.org/licenses/mit-license.php */ //package com.java2s; import java.nio.ByteBuffer; public class Main { /** * Convert remaining byte buffer to byte array. * * @param buffer Source byte buffer * @return Remaining byte array. */ public static byte[] toBytesRemaining(ByteBuffer buffer) { byte[] array = new byte[buffer.remaining()]; buffer.get(array); return array; } }