Java ByteBuffer Resize increaseByteBuffer(ByteBuffer byteBuffer, int increase)

Here you can find the source of increaseByteBuffer(ByteBuffer byteBuffer, int increase)

Description

increase ByteBuffer

License

Apache License

Parameter

Parameter Description
byteBuffer a parameter

Declaration


public static final ByteBuffer increaseByteBuffer(ByteBuffer byteBuffer, int increase) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.nio.ByteBuffer;

public class Main {
    /**//from w  ww.  j a v a 2  s .c  om
     * increase ByteBuffer
     * 
     * @param byteBuffer
     * @return
     */

    public static final ByteBuffer increaseByteBuffer(ByteBuffer byteBuffer, int increase) {
        int capacity = byteBuffer.limit() + increase;
        ByteBuffer result = (byteBuffer.isDirect() ? ByteBuffer.allocateDirect(capacity)
                : ByteBuffer.allocate(capacity));
        result.order(byteBuffer.order());
        byteBuffer.flip();
        result.put(byteBuffer);
        return result;
    }
}

Related

  1. check(BufferedImage image, int resizeWidth, int resizeHeight)
  2. increaseBufferCapatity(ByteBuffer byteBuffer)
  3. performResize(BufferedImage source, int newWidth, int newHeight)
  4. resize(ByteBuffer buffer)
  5. resize(ByteBuffer oldBuffer, int newSize)
  6. resizeBuffer(final ByteBuffer in)