Java ByteBuffer Capacity grow(ByteBuffer buffer, int minCapacityIncrease)

Here you can find the source of grow(ByteBuffer buffer, int minCapacityIncrease)

Description

grow

License

Apache License

Declaration

private static ByteBuffer grow(ByteBuffer buffer, int minCapacityIncrease) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    private static ByteBuffer grow(ByteBuffer buffer, int minCapacityIncrease) {
        ByteBuffer tmp = ByteBuffer
                .allocate(Math.max(buffer.capacity() << 1, buffer.capacity() + minCapacityIncrease));
        buffer.flip();/* w  w  w  .j  a  va2s. c  o  m*/
        tmp.put(buffer);
        return tmp;
    }
}

Related

  1. ensureCapacity(ByteBuffer buffer, int capacity)
  2. ensureCapacity(ByteBuffer existingBuffer, int newLength)
  3. ensureCapacity(ByteBuffer original, int newCapacity)
  4. expand(ByteBuffer buffer, int newCapacity)
  5. getByteBuffer(int capacity)
  6. growBuffer(ByteBuffer b, int newCapacity)
  7. increaseCapacity(ByteBuffer buffer, int size)
  8. leByteBuffer(int capacity)
  9. nativeByteBuffer(int capacity)