java.io
Class BufferedOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--java.io.BufferedOutputStream

public class BufferedOutputStream
extends FilterOutputStream

BufferedOutputStream adds functionality to another output stream. The main functionality it adds is the ability to buffer the output before writing it to the underlying stream.


Field Summary
protected  byte[] buf
           
protected  int count
           
 
Constructor Summary
BufferedOutputStream(OutputStream os)
          Creates a BufferedOutputStream adding functionality to the passed output stream.
BufferedOutputStream(OutputStream os, int size)
          Creates a BufferedOutputStream adding functionality to the passed output stream.
 
Method Summary
 void flush()
          Writes the contents of the buffer to the underlying stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from offset off of the passed array b to the buffer.
 void write(int i)
          Writes a single character (passed as an integer value) to the buffer.
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 

Field Detail

buf

protected byte[] buf

count

protected int count
Constructor Detail

BufferedOutputStream

public BufferedOutputStream(OutputStream os)
Creates a BufferedOutputStream adding functionality to the passed output stream.

Parameters:
os - underlying output stream.

BufferedOutputStream

public BufferedOutputStream(OutputStream os,
                            int size)
Creates a BufferedOutputStream adding functionality to the passed output stream. A buffer of the passed size is allocated to buffer the data that is written to the stream.

Parameters:
os - underlying output stream.
size - buffer size.
Method Detail

flush

public void flush()
           throws IOException
Writes the contents of the buffer to the underlying stream.

Overrides:
flush in class FilterOutputStream
Throws:
IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from offset off of the passed array b to the buffer. As with all write operations to a buffered output stream the buffer will be automatically flushed if full.

Overrides:
write in class FilterOutputStream
Parameters:
b - data.
off - start offset within data.
len - number of bytes to be written.
Throws:
IOException - if an I/O error occurs.

write

public void write(int i)
           throws IOException
Writes a single character (passed as an integer value) to the buffer. As with all write operations to a buffered output stream the buffer will be automatically flushed if full.

Overrides:
write in class FilterOutputStream
Parameters:
i - character to be written.
Throws:
IOException - if an I/O error occurs.