Here you can find the source of resizeBuffer(final ByteBuffer in)
Parameter | Description |
---|---|
in | a parameter |
private static ByteBuffer resizeBuffer(final ByteBuffer in)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { private static final int READ_BLOCK = 8192; /**/*w w w. ja v a2 s. co m*/ * A helper method to resize byte buffer upon read. * * @param in * @return */ private static ByteBuffer resizeBuffer(final ByteBuffer in) { if (in.remaining() < READ_BLOCK) { // create new buffer with double capacity final ByteBuffer result = ByteBuffer.allocate(in.capacity() * 2); // flip the in buffer in preparation for it to be copied into the newly created larger buffer in.flip(); // copy the in buffer into new buffer result.put(in); return result; } return in; } }