t { Buffer buffer = new Buffer(8); // 8 bytes allocated by the constructor assert(buffer.capacity == 8); // writing 4 bytes does not alter the capacity buffer.write(0); assert(buffer.capacity == 8); // writing 8 bytes requires a new allocation (because 4 + 8 is // higher than the current capacity of 8). // The new capacity is rounded up to the nearest multiple of the chunk size. buffer.write(0L); assert(buffer.capacity == 16);
Creates a buffer specifying the chunk size. This should be the default constructor for re-used buffers and input buffers.