public class ByteBufferOutputStream extends OutputStream
Modifier and Type | Field and Description |
---|---|
protected byte[] |
_buf |
Constructor and Description |
---|
ByteBufferOutputStream()
Constructor.
|
ByteBufferOutputStream(int capacity)
Constructor.
|
ByteBufferOutputStream(int capacity,
int preReserve)
Constructor.
|
ByteBufferOutputStream(int bufferSize,
int preReserve,
int postReserve)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
bufferSize() |
int |
capacity() |
void |
close() |
void |
destroy() |
void |
ensureCapacity(int n) |
void |
ensureReserve(int n) |
void |
ensureSize(int bufSize) |
void |
ensureSize(int bufSize,
int pre,
int post) |
void |
ensureSpareCapacity(int n) |
void |
flush() |
boolean |
isFixed() |
int |
postReserve() |
void |
postwrite(byte b)
Write bytes into the postreserve.
|
void |
postwrite(byte[] b,
int offset,
int length)
Write bytes into the postreserve.
|
int |
preReserve() |
void |
prewrite(byte[] b)
Write byte array to start of the buffer.
|
void |
prewrite(byte[] b,
int offset,
int length)
Write byte range to start of the buffer.
|
void |
prewrite(int b)
Write byte to start of the buffer.
|
void |
reset(int reserve) |
void |
resetStream() |
void |
setFixed(boolean fixed) |
int |
size() |
int |
spareCapacity() |
void |
write(byte[] b) |
void |
write(byte[] b,
int offset,
int length) |
void |
write(int b) |
void |
writeTo(OutputStream out) |
public ByteBufferOutputStream()
public ByteBufferOutputStream(int capacity)
capacity
- Buffer capacitypublic ByteBufferOutputStream(int capacity, int preReserve)
capacity
- Buffer capacity.preReserve
- The reserve of byte for prependingpublic ByteBufferOutputStream(int bufferSize, int preReserve, int postReserve)
bufferSize
- The size of the buffer == capacity+preReserve+postReservepreReserve
- The reserve of byte for prependingpostReserve
- The reserve of byte for appendingpublic boolean isFixed()
public void setFixed(boolean fixed)
fixed
- True if the buffer cannot be expandedpublic int size()
public int bufferSize()
public int capacity()
public int spareCapacity()
public int preReserve()
public int postReserve()
public void writeTo(OutputStream out) throws IOException
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int offset, int length) throws IOException
write
in class OutputStream
IOException
public void prewrite(int b)
b
- public void prewrite(byte[] b)
b
- public void prewrite(byte[] b, int offset, int length)
b
- offset
- length
- public void postwrite(byte b) throws IOException
b
- IOException
public void postwrite(byte[] b, int offset, int length) throws IOException
b
- offset
- length
- IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void resetStream()
public void reset(int reserve)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void destroy()
public void ensureReserve(int n)
public void ensureSize(int bufSize) throws IOException
IOException
public void ensureSize(int bufSize, int pre, int post) throws IOException
IOException
public void ensureSpareCapacity(int n) throws IOException
IOException
public void ensureCapacity(int n) throws IOException
IOException
Copyright © 2013. All rights reserved.