|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectOutputStream
FastBufferedOutputStream
public class FastBufferedOutputStream
Lightweight, unsynchronised, aligned output stream buffering class.
This class provides buffering for output streams, but it does so with
purposes and an internal logic that are radically different from the ones
adopted in BufferedOutputStream
.
All methods are unsychronised. Moreover, it is guaranteed that
all writes performed by this class will be
multiples of the given buffer size.
If, for instance, you use the default buffer size, writes will be performed
on the underlying input stream in multiples of 16384 bytes. This is very
important on operating systems that optimise disk reads on disk block
boundaries. If you flush()
the stream, the buffer will be emptied,
but it will realign again as soon as possible.
Field Summary | |
---|---|
protected int |
avail
The number of buffer bytes available starting from pos . |
protected byte[] |
buffer
The internal buffer. |
static int |
DEFAULT_BUFFER_SIZE
The default size of the internal buffer in bytes (8Ki). |
protected OutputStream |
os
The underlying output stream. |
protected int |
pos
The current position in the buffer. |
Constructor Summary | |
---|---|
FastBufferedOutputStream(OutputStream os)
Creates a new fast buffered ouptut stream by wrapping a given output stream with a buffer of DEFAULT_BUFFER_SIZE bytes. |
|
FastBufferedOutputStream(OutputStream os,
int bufSize)
Creates a new fast buffered output stream by wrapping a given output stream with a given buffer size. |
Method Summary | |
---|---|
void |
close()
|
void |
flush()
|
void |
write(byte[] b,
int offset,
int length)
|
void |
write(int b)
|
Methods inherited from class OutputStream |
---|
write |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
protected byte[] buffer
protected int pos
protected int avail
pos
. Note
that in case flush()
has been called, the number of available
buffer bytes might be less than buffer.length
−pos
.
protected OutputStream os
Constructor Detail |
---|
public FastBufferedOutputStream(OutputStream os, int bufSize)
os
- an output stream to wrap.bufSize
- the size in bytes of the internal buffer.public FastBufferedOutputStream(OutputStream os)
DEFAULT_BUFFER_SIZE
bytes.
os
- an output stream to wrap.Method Detail |
---|
public void write(int 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 flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |