public class UnsynchronizedBuffer extends OutputStream
Constructor and Description |
---|
UnsynchronizedBuffer()
Creates a new writer.
|
UnsynchronizedBuffer(int initialCapacity)
Creates a new writer.
|
Modifier and Type | Method and Description |
---|---|
int |
getOffset() |
long |
getSize() |
static int |
nextArraySize(int i)
Determines what next array size should be by rounding up to next power of two.
|
void |
reset()
Resets the internal pointer into the buffer.
|
byte[] |
toArray()
Gets (a copy of) the contents of this writer's buffer.
|
void |
write(byte[] bytes,
int off,
int length)
Adds bytes to this writer's buffer.
|
void |
write(int b) |
close, flush, write
public UnsynchronizedBuffer()
public UnsynchronizedBuffer(int initialCapacity)
initialCapacity
- initial byte capacitypublic void write(byte[] bytes, int off, int length)
write
in class OutputStream
bytes
- byte arrayoff
- offset into array to start copying byteslength
- number of bytes to addIndexOutOfBoundsException
- if off or length are invalidpublic void write(int b) throws IOException
write
in class OutputStream
IOException
public byte[] toArray()
public void reset()
public int getOffset()
public long getSize()
public static int nextArraySize(int i)
i
- current array sizeIllegalArgumentException
- if i is negativeCopyright © 2012-2025 Apache Software Foundation. All Rights Reserved.