public class FastByteArrayWrapper extends Object
toByteArray()
and toString()
.
Closing a ByteArrayOutputStream has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf
The buffer where data is stored.
|
protected int |
count
The number of valid bytes in the buffer.
|
Constructor and Description |
---|
FastByteArrayWrapper()
Default constructor
Creates a new byte array output stream. |
FastByteArrayWrapper(byte[] buffer)
Build a
FastByteArrayWrapper with the inner buffer specified as
argument |
FastByteArrayWrapper(byte[] buffer,
int count)
Build a
FastByteArrayWrapper with the inner buffer specified as
argument. |
FastByteArrayWrapper(int size)
Creates a new byte array output stream, with a buffer capacity of the
specified size, in bytes.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getByteArray()
Creates a newly allocated byte array.
|
void |
reset()
Resets the
count field of this byte array wrapper to zero,
so that all currently accumulated values in the byte array is discarded. |
int |
size()
Returns the current size of the buffer.
|
String |
toString()
Converts the buffer's contents into a string, translating bytes into
characters according to the platform's default character encoding.
|
void |
write(byte[] b)
Writes
b.length bytes from the specified byte array
starting at offset 0 to this byte array wrapper. |
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array starting at
offset off to this byte array wrapper. |
void |
write(int b)
Writes the specified byte to this byte array wrapper.
|
protected byte[] buf
protected int count
public FastByteArrayWrapper()
public FastByteArrayWrapper(byte[] buffer)
FastByteArrayWrapper
with the inner buffer specified as
argumentbuffer
- the inner buffer used by this FastByteArrayWrapper
public FastByteArrayWrapper(byte[] buffer, int count)
FastByteArrayWrapper
with the inner buffer specified as
argument.buffer
- the inner buffer used by this FastByteArrayWrapper
count
- the number of valid bytes in the provided bufferpublic FastByteArrayWrapper(int size)
size
- the initial size.IllegalArgumentException
- if size is negative.public void write(int b)
b
- the byte to be written.public void write(byte[] b, int off, int len)
len
bytes from the specified byte array starting at
offset off
to this byte array wrapper.b
- the data.off
- the start offset in the data.len
- the number of bytes to write.public void write(byte[] b) throws IOException
b.length
bytes from the specified byte array
starting at offset 0 to this byte array wrapper.b
- the data.IOException
public void reset()
count
field of this byte array wrapper to zero,
so that all currently accumulated values in the byte array is discarded.public byte[] getByteArray()
ByteArrayOutputStream.size()
public int size()
count
field, which is the number
of valid bytes in the buffer.ByteArrayOutputStream.count
Copyright © 2006–2016 GeoSolutions. All rights reserved.