Contents | Prev | Next | Index

22.20 The Class java.io.BufferedOutputStream

A BufferedOutputStream adds functionality to another output stream, namely the ability to buffer the output. When the BufferedOutputStream is created, an internal buffer array is created. As bytes are written to the stream, they are stored in the internal buffer, which is flushed as necessary, thereby performing output to the contained output stream in large blocks rather than a byte at a time.

public class BufferedOutputStream extends FilterOutputStream {
	protected byte[] buf;
	protected int count;
	public BufferedOutputStream(OutputStream out);
	public BufferedOutputStream(OutputStream out, int size);
	public void write(int b) throws IOException;
	public void write(byte[] b)
		throws IOException, NullPointerException;
	public void write(byte[] b, int off, int len)
		throws IOException, NullPointerException,
			IndexOutOfBoundsException;
	public void flush() throws IOException;
}

22.20.1 protected byte[] buf;

The internal buffer array.

22.20.2 protected int count;

This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data.

22.20.3 public BufferedOutputStream(OutputStream out)

This constructor initializes a newly created BufferedOutputStream by saving its argument, the input stream out, for later use. An internal buffer array is created and stored in buf.

22.20.4 public BufferedOutputStream(OutputStream out, int size)

This constructor initializes a newly created BufferedOutputStream by saving its argument, the input stream out, for later use. An internal buffer array of length size is created and stored in buf.

22.20.5 public void write(int b) throws IOException

See the general contract of the write method of OutputStream (§22.15.1).

Overrides the write method of FilterOutputStream (§22.19.3).

22.20.6 public void write(byte[] b)
throws IOException, NullPointerException

See the general contract of the write method of OutputStream (§22.15.2).

Overrides the write method of FilterOutputStream (§22.19.4).

22.20.7 public void write(byte[] b, int off, int len)
throws IOException, NullPointerException, IndexOutOfBoundsException

See the general contract of the write method of OutputStream (§22.15.3).

Overrides the write method of FilterOutputStream (§22.19.5).

22.20.8 public void flush() throws IOException

See the general contract of the flush method of OutputStream (§22.15.4).

Overrides the flush method of FilterOutputStream (§22.19.6).


Contents | Prev | Next | Index

Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com