Here you can find the source of resizeByteBuffer(ByteBuffer buf, long size)
public static ByteBuffer resizeByteBuffer(ByteBuffer buf, long size)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static ByteBuffer resizeByteBuffer(ByteBuffer buf, long size) { ByteBuffer ret = ByteBuffer.allocateDirect((int) size); if (ret != null) { if (null != buf) { ret.put(buf);// w ww . j a v a 2 s . c o m ret.flip(); } } return ret; } }