Contents | Prev | Next | Index

22.17 The Class java.io.PipedOutputStream

A piped output stream should be connected to a piped input stream; the piped input stream then provides whatever data bytes are written to the piped output stream. Typically, data is written to a PipeOutputStream object by one thread and data is read from the corresponding PipedInputStream (§22.5) by some other thread. Attempting to use both objects from a single thread is not recommended, as it may deadlock the thread.

public class PipedOutputStream extends OutputStream {
	public PipedOutputStream(PipedInputStream snk)
		throws IOException;
	public PipedOutputStream();
	public void connect(PipedInputStream snk)
		throws IOException;
	public void write(int b) throws IOException;
	public void write(byte[] b, int off, int len)
		throws IOException, NullPointerException,
			IndexOutOfBoundsException;
	public void close() throws IOException;
}

22.17.1 public PipedOutputStream(PipedInputStream snk)
throws IOException

This constructor initializes a newly created PipedOutputStream so that it is connected to the piped input stream snk. Data bytes written to this stream will then be available as input from snk.

22.17.2 public PipedOutputStream()

This constructor initializes a newly created PipedOutputStream so that it is not yet connected. It must be connected to a PipedInputStream before being used.

22.17.3 public void connect(PipedInputStream snk)
throws IOException

The connect method causes this piped output stream to be connected to the piped input stream snk. If this object is already connected to some other piped input stream, an IOException is thrown.

If snk is an unconnected piped input stream and src is an unconnected piped output stream, they may be connected by either the call:

src.connect(snk)
or the call:

snk.connect(src)
The two calls have the same effect.

22.17.4 public void write(int b) throws IOException

If a thread was reading data bytes from the connected piped input stream, but the thread is no longer alive, then an IOException is thrown.

Implements the write method of OutputStream (§22.15.1).

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

If a thread was reading data bytes from the connected piped input stream, but the thread is no longer alive, then an IOException is thrown.

Overrides the write method of OutputStream (§22.15.3).

22.17.6 public void close() throws IOException

This piped output stream is closed and may no longer be used for writing bytes.

Overrides the close method of OutputStream (§22.15.5).


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



Spec-Zone.ru - all specs in one place



free hit counter