Creates a byte buffer based on a newly allocated byte array. @param capacity the capacity of the new buffer @return the created byte buffer. @throws IllegalArgumentException if capacity < 0.
(int capacity)
| 46 | * if {@code capacity < 0}. |
| 47 | */ |
| 48 | public static ByteBuffer allocate(int capacity) { |
| 49 | if (capacity < 0) { |
| 50 | throw new IllegalArgumentException(); |
| 51 | } |
| 52 | return BufferFactory.newByteBuffer(capacity); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a direct byte buffer based on a newly allocated memory block. |
no test coverage detected