Here you can find the source of resize(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | a parameter |
public static ByteBuffer resize(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**/* ww w. j a v a2 s. c o m*/ * Allocate a larger buffer that contains the data of an existing buffer. * @param buffer * @return */ public static ByteBuffer resize(ByteBuffer buffer) { int capacity = buffer.capacity(); if (capacity > 2048) capacity += 1024; else capacity *= 2; ByteBuffer newBuffer = ByteBuffer.allocate(capacity); buffer.flip(); newBuffer.put(buffer); return newBuffer; } }