hudson.remoting
Class FastPipedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by hudson.remoting.FastPipedInputStream
All Implemented Interfaces:
java.io.Closeable

public class FastPipedInputStream
extends java.io.InputStream

This class is equivalent to java.io.PipedInputStream. 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 FastPipedOutputStream.

Author:
WD
See Also:
FastPipedOutputStream

Constructor Summary
FastPipedInputStream()
          Creates an unconnected PipedInputStream with a default buffer size.
FastPipedInputStream(FastPipedOutputStream source)
          Creates a PipedInputStream with a default buffer size and connects it to source.
FastPipedInputStream(FastPipedOutputStream source, int bufferSize)
          Creates a PipedInputStream with buffer size bufferSize and connects it to source.
 
Method Summary
 int available()
           
 void close()
           
 void connect(FastPipedOutputStream source)
           
protected  void finalize()
           
 void mark(int readLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class java.io.InputStream
reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastPipedInputStream

public FastPipedInputStream()
Creates an unconnected PipedInputStream with a default buffer size.


FastPipedInputStream

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

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

FastPipedInputStream

public FastPipedInputStream(FastPipedOutputStream source,
                            int bufferSize)
                     throws java.io.IOException
Creates a PipedInputStream with buffer size bufferSize and connects it to source.

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

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

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

connect

public void connect(FastPipedOutputStream source)
             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

mark

public void mark(int readLimit)
Overrides:
mark in class java.io.InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException - The pipe is not connected.


Copyright © 2013. All Rights Reserved.