|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream org.archive.io.RecyclingFastBufferedOutputStream
public class RecyclingFastBufferedOutputStream
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.
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 (16Ki). |
protected java.io.OutputStream |
os
The underlying output stream. |
protected int |
pos
The current position in the buffer. |
Constructor Summary | |
---|---|
RecyclingFastBufferedOutputStream(java.io.OutputStream os)
Creates a new fast buffered ouptut stream by wrapping a given output stream with a buffer of DEFAULT_BUFFER_SIZE bytes. |
|
RecyclingFastBufferedOutputStream(java.io.OutputStream os,
byte[] buffer)
Creates a new fast buffered output stream by wrapping a given output stream, using a given buffer |
|
RecyclingFastBufferedOutputStream(java.io.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 |
write(byte[] b,
int offset,
int length)
|
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
---|
flush, write |
Methods inherited from class java.lang.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
.
protected java.io.OutputStream os
Constructor Detail |
---|
public RecyclingFastBufferedOutputStream(java.io.OutputStream os, byte[] buffer)
os
- an output stream to wrap.buffer
- buffer to use internally.public RecyclingFastBufferedOutputStream(java.io.OutputStream os, int bufSize)
os
- an output stream to wrap.bufSize
- the size in bytes of the internal buffer.public RecyclingFastBufferedOutputStream(java.io.OutputStream os)
DEFAULT_BUFFER_SIZE
bytes.
os
- an output stream to wrap.Method Detail |
---|
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int offset, int length) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.OutputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |