|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
public class BufferedOutputStream
This class accumulates bytes written in a buffer instead of immediately writing the data to the underlying output sink. The bytes are instead as one large block when the buffer is filled, or when the stream is closed or explicitly flushed. This mode operation can provide a more efficient mechanism for writing versus doing numerous small unbuffered writes.
Field Summary | |
---|---|
protected byte[] |
buf
This is the internal byte array used for buffering output before writing it. |
protected int |
count
This is the number of bytes that are currently in the buffer and are waiting to be written to the underlying stream. |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
BufferedOutputStream(OutputStream out)
This method initializes a new BufferedOutputStream instance
that will write to the specified subordinate OutputStream
and which will use a default buffer size of 512 bytes. |
|
BufferedOutputStream(OutputStream out,
int size)
This method initializes a new BufferedOutputStream instance
that will write to the specified subordinate OutputStream
and which will use the specified buffer size |
Method Summary | |
---|---|
void |
flush()
This method causes any currently buffered bytes to be immediately written to the underlying output stream. |
void |
write(byte[] buf,
int offset,
int len)
This method writes len bytes from the byte array
buf starting at position offset in the buffer. |
void |
write(int b)
This method writes a single byte of data. |
Methods inherited from class java.io.FilterOutputStream |
---|
close, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] buf
protected int count
Constructor Detail |
---|
public BufferedOutputStream(OutputStream out)
BufferedOutputStream
instance
that will write to the specified subordinate OutputStream
and which will use a default buffer size of 512 bytes.
out
- The underlying OutputStream
to write data topublic BufferedOutputStream(OutputStream out, int size)
BufferedOutputStream
instance
that will write to the specified subordinate OutputStream
and which will use the specified buffer size
out
- The underlying OutputStream
to write data tosize
- The size of the internal bufferMethod Detail |
---|
public void flush() throws IOException
flush
in interface Flushable
flush
in class FilterOutputStream
IOException
- If an error occurspublic void write(int b) throws IOException
write
in class FilterOutputStream
b
- The byte of data to be written, passed as an int
IOException
- If an error occurspublic void write(byte[] buf, int offset, int len) throws IOException
len
bytes from the byte array
buf
starting at position offset
in the buffer.
These bytes will be written to the internal buffer. However, if this
write operation fills the buffer, the buffer will be flushed to the
underlying output stream.
write
in class FilterOutputStream
buf
- The array of bytes to write.offset
- The index into the byte array to start writing from.len
- The number of bytes to write.
IOException
- If an error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |