Here you can find the source of ensureCapacity(byte[] bytes, int capacity)
Parameter | Description |
---|---|
bytes | a parameter |
size | a parameter |
factor | a parameter |
private static byte[] ensureCapacity(byte[] bytes, int capacity)
//package com.java2s; //License from project: Apache License import java.util.Arrays; public class Main { /**/*from w w w . j av a2s. co m*/ * Utility method used to ensure the capacity of byte array. * * @param bytes * @param size * @param factor * @return */ private static byte[] ensureCapacity(byte[] bytes, int capacity) { if (bytes.length < capacity) { int newsize = Math.max(1, bytes.length) << 1; bytes = Arrays.copyOf(bytes, newsize); } return bytes; } }