public class FastByteArrayOutputStream extends OutputStream
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_INCREASE_SIZE
Buffer increase size, zero means double.
|
static int |
DEFAULT_INITIAL_SIZE
Buffer initial size.
|
Constructor and Description |
---|
FastByteArrayOutputStream()
Ctor.
|
FastByteArrayOutputStream(byte[] buffer)
Ctor.
|
FastByteArrayOutputStream(byte[] buffer,
int increase)
Ctor.
|
FastByteArrayOutputStream(int initialSize)
Ctor.
|
FastByteArrayOutputStream(int initialSize,
int increaseSize)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
void |
addSize(int sizeAdded)
Add number of bytes to size.
|
byte[] |
getBufferBytes()
Returns the buffer itself.
|
int |
getBufferLength()
Returns the length.
|
int |
getBufferOffset()
Returns the offset, always zero.
|
byte[] |
getByteArrayFast()
Fast getter checking if the byte array matches the requested length and returnin the buffer itself if it does.
|
byte[] |
getByteArrayWithCopy()
Returns the byte array.
|
void |
makeSpace(int sizeNeeded)
Increase buffer size.
|
void |
reset()
Reset buffer.
|
int |
size()
Returns buffer size.
|
String |
toString() |
String |
toString(String encoding)
Outputs contents.
|
void |
write(byte[] fromBuf) |
void |
write(byte[] fromBuf,
int offset,
int length) |
void |
write(int b)
Write byte.
|
void |
writeFast(byte[] fromBuf)
Fast write.
|
void |
writeFast(byte[] fromBuf,
int offset,
int length)
Fast write.
|
void |
writeFast(int b)
Fast write.
|
void |
writeTo(OutputStream out)
Write bytes to another stream.
|
close, flush
public static final int DEFAULT_INITIAL_SIZE
public static final int DEFAULT_INCREASE_SIZE
public FastByteArrayOutputStream(byte[] buffer)
buffer
- to writepublic FastByteArrayOutputStream(byte[] buffer, int increase)
buffer
- to writeincrease
- zero forpublic FastByteArrayOutputStream()
public FastByteArrayOutputStream(int initialSize)
initialSize
- initial sizepublic FastByteArrayOutputStream(int initialSize, int increaseSize)
initialSize
- initial sizeincreaseSize
- increase sizepublic int size()
public void reset()
public void write(int b) throws IOException
write
in class OutputStream
b
- byte to writeIOException
- for io errorspublic void write(byte[] fromBuf) throws IOException
write
in class OutputStream
IOException
public void write(byte[] fromBuf, int offset, int length) throws IOException
write
in class OutputStream
IOException
public void writeTo(OutputStream out) throws IOException
out
- other streamIOException
- if a write exception occurspublic String toString(String encoding) throws UnsupportedEncodingException
encoding
- to useUnsupportedEncodingException
- when encoding is not supportedpublic byte[] getByteArrayWithCopy()
public byte[] getByteArrayFast()
public final void writeFast(int b)
b
- byte to writepublic final void writeFast(byte[] fromBuf)
fromBuf
- to writepublic final void writeFast(byte[] fromBuf, int offset, int length)
fromBuf
- buffer to writeoffset
- offset of write fromlength
- length to writepublic byte[] getBufferBytes()
public int getBufferOffset()
public int getBufferLength()
public void makeSpace(int sizeNeeded)
sizeNeeded
- bytes needed.public void addSize(int sizeAdded)
sizeAdded
- to be addedCopyright © 2005–2021. All rights reserved.