hudson.remoting
Class FastPipedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by hudson.remoting.FastPipedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class FastPipedOutputStream
extends java.io.OutputStream

This class is equivalent to java.io.PipedOutputStream. In the interface it only adds a constructor which allows for specifying the buffer size. Its implementation, however, is much simpler and a lot more efficient than its equivalent. It doesn't rely on polling. Instead it uses proper synchronization with its counterpart FastPipedInputStream.

Author:
WD
See Also:
FastPipedOutputStream

Constructor Summary
FastPipedOutputStream()
          Creates an unconnected PipedOutputStream.
FastPipedOutputStream(FastPipedInputStream sink)
          Creates a PipedOutputStream with a default buffer size and connects it to sink.
FastPipedOutputStream(FastPipedInputStream sink, int bufferSize)
          Deprecated. as of 1.350 bufferSize parameter is ignored.
 
Method Summary
 void close()
           
 void connect(FastPipedInputStream sink)
           
protected  void finalize()
           
 void flush()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastPipedOutputStream

public FastPipedOutputStream()
Creates an unconnected PipedOutputStream.


FastPipedOutputStream

public FastPipedOutputStream(FastPipedInputStream sink)
                      throws java.io.IOException
Creates a PipedOutputStream with a default buffer size and connects it to sink.

Throws:
java.io.IOException - It was already connected.

FastPipedOutputStream

public FastPipedOutputStream(FastPipedInputStream sink,
                             int bufferSize)
                      throws java.io.IOException
Deprecated. as of 1.350 bufferSize parameter is ignored.

Creates a PipedOutputStream with buffer size bufferSize and connects it to sink.

Throws:
java.io.IOException - It was already connected.
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - The pipe is not connected.

connect

public void connect(FastPipedInputStream sink)
             throws java.io.IOException
Throws:
java.io.IOException - The pipe is already connected.

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException - The pipe is not connected or a reader has closed it.


Copyright © 2012. All Rights Reserved.