com.knowgate.dfs
Class StreamPipe

java.lang.Object
  extended by com.knowgate.dfs.StreamPipe

public class StreamPipe
extends java.lang.Object

This class links input and output streams so that data taken from input stream is transfered to the output stream. This class can be used to connect standard input/ouput stream of Java application with output/input streams of spawned child process, so that all user's input is redirected to the child and all it's output is visible for the user.

This class starts a thread, which transfers data from input stream to output stream until End Of File is reached or IOException caused by IO error is catched.


Constructor Summary
StreamPipe()
          Create synchronous stream conector.
StreamPipe(boolean bSync)
          Create synchronous or asynchronous stream conector.
 
Method Summary
 void between(java.io.InputStream in, java.io.OutputStream out)
          Establish connection between input and output streams with default buffer size and no auto-flush.
 void between(java.io.InputStream in, java.io.OutputStream out, int bufferSize)
          Establish connection between input and output streams with specified size of buffer used for data transfer and no auto-flush.
 void between(java.io.InputStream in, java.io.OutputStream out, int bufferSize, boolean autoFlush)
          Establish connection between input and output streams with specified size of buffer used for data transfer.
static void between(java.lang.String sFilePath, java.io.OutputStream oOutStrm)
          Establish synchronous connection between a file and an output stream with specified size of buffer used for data transfer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamPipe

public StreamPipe()
Create synchronous stream conector. between() methods do not return until end of input stream is reached and written into ouput stream.


StreamPipe

public StreamPipe(boolean bSync)
Create synchronous or asynchronous stream conector. between() methods do not return until end of input stream is reached and written into ouput stream.

Method Detail

between

public void between(java.io.InputStream in,
                    java.io.OutputStream out,
                    int bufferSize,
                    boolean autoFlush)
             throws java.io.IOException
Establish connection between input and output streams with specified size of buffer used for data transfer.

Parameters:
in - input stream
out - output stream
bufferSize - size of buffer used to transfer data from the input stream to the output stream
autoFlush - if set to true OutputStream.flush() method will be called each time bufferSize bytes are written into output stream
Throws:
java.io.IOException

between

public void between(java.io.InputStream in,
                    java.io.OutputStream out,
                    int bufferSize)
             throws java.io.IOException
Establish connection between input and output streams with specified size of buffer used for data transfer and no auto-flush.

Parameters:
in - input stream
out - output stream
Throws:
java.io.IOException

between

public void between(java.io.InputStream in,
                    java.io.OutputStream out)
             throws java.io.IOException
Establish connection between input and output streams with default buffer size and no auto-flush.

Parameters:
in - input stream
out - output stream
Throws:
java.io.IOException

between

public static void between(java.lang.String sFilePath,
                           java.io.OutputStream oOutStrm)
                    throws java.io.IOException,
                           java.io.FileNotFoundException
Establish synchronous connection between a file and an output stream with specified size of buffer used for data transfer. autoFlush is set to false and buffer size is set to 8000 bytes.

Parameters:
sFilePath - input stream
oOutStrm - output stream
Throws:
java.io.IOException
java.io.FileNotFoundException
Since:
3.0