java.io
Class PipedOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.PipedOutputStream

public class PipedOutputStream
extends OutputStream

Piped output stream, must be connected to a PipedInputStream. A thread reading from a PipedInputStream receives data from a thread writing to the PipedOutputStream it is connected to.

See Also:
PipedInputStream

Constructor Summary
PipedOutputStream()
          Creates an output file that isn't connected to anything (yet).
PipedOutputStream(PipedInputStream snk)
          Creates an output file connected to the specified PipedInputStream.
 
Method Summary
 void close()
          Closes the stream.
 void connect(PipedInputStream snk)
          Connect this output stream to a receiver.
 void flush()
          Flushes the stream.
 void write(byte[] b, int off, int len)
          Writes a sub array of bytes.
 void write(int b)
          Write a byte.
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipedOutputStream

public PipedOutputStream(PipedInputStream snk)
                  throws IOException
Creates an output file connected to the specified PipedInputStream.

Parameters:
snk - The InputStream to connect to.

PipedOutputStream

public PipedOutputStream()
Creates an output file that isn't connected to anything (yet). It must be connected before being used.

Method Detail

connect

public void connect(PipedInputStream snk)
             throws IOException
Connect this output stream to a receiver.

Parameters:
snk - The InputStream to connect to.
IOException

write

public void write(int b)
           throws IOException
Write a byte. This method will block until the byte is actually written.

Specified by:
write in class OutputStream
Parameters:
b - the byte to be written
Throws:
IOException - If an I/O error has occurred.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes a sub array of bytes.

Overrides:
write in class OutputStream
Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
Throws:
IOException - If an I/O error has occurred.

flush

public void flush()
           throws IOException
Flushes the stream. This will notify any readers that bytes are waiting in the pipe.

Overrides:
flush in class OutputStream
Throws:
IOException - If an I/O error has occurred.

close

public void close()
           throws IOException
Closes the stream. This method must be called to release any resources associated with the stream.

Overrides:
close in class OutputStream
Throws:
IOException - If an I/O error has occurred.