public class UnsynchronizedBuffer extends OutputStream
| Modifier and Type | Field and Description |
|---|---|
(package private) byte[] |
data |
(package private) int |
initialCapacity |
private static int |
LARGE_BUFFER_SIZE |
(package private) int |
offset |
| 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.
|
private void |
reserve(int l) |
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, writeprivate static final int LARGE_BUFFER_SIZE
final int initialCapacity
int offset
byte[] data
public UnsynchronizedBuffer()
public UnsynchronizedBuffer(int initialCapacity)
initialCapacity - initial byte capacityprivate void reserve(int l)
public void write(byte[] bytes,
int off,
int length)
write in class OutputStreambytes - 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 OutputStreamIOExceptionpublic 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–2016 The Apache Software Foundation. All rights reserved.