The im4java Library, Version 1.4.0

org.im4java.process
Class Pipe

java.lang.Object
  extended by org.im4java.process.Pipe
All Implemented Interfaces:
ErrorConsumer, InputProvider, OutputConsumer

public class Pipe
extends java.lang.Object
implements InputProvider, OutputConsumer, ErrorConsumer

This class implements a pipe. Useful for piping input to a process or piping output/error from a process to other streams.

You can use the same Pipe-object for both ends of a process-pipeline. But you cannot use the same Pipe-object as an OutputConsumer and ErrorConsumer at the same time.

Since:
0.95
Version:
$Revision: 1.8 $
Author:
$Author: bablokb $

Field Summary
static int BUFFER_SIZE
          Default buffer size of the pipe.
 
Constructor Summary
Pipe(java.io.InputStream pSource, java.io.OutputStream pSink)
          Constructor.
 
Method Summary
 void consumeError(java.io.InputStream pInputStream)
          The ErrorConsumer must read the error of a process from the given InputStream.
 void consumeOutput(java.io.InputStream pInputStream)
          The OutputConsumer must read the output of a process from the given InputStream.
 void provideInput(java.io.OutputStream pOutputStream)
          The InputProvider must write the input to the given OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
Default buffer size of the pipe. Currently 64KB.

See Also:
Constant Field Values
Constructor Detail

Pipe

public Pipe(java.io.InputStream pSource,
            java.io.OutputStream pSink)
Constructor. At least one of the arguments should not be null.

Method Detail

provideInput

public void provideInput(java.io.OutputStream pOutputStream)
                  throws java.io.IOException
The InputProvider must write the input to the given OutputStream.

Specified by:
provideInput in interface InputProvider
Throws:
java.io.IOException

consumeOutput

public void consumeOutput(java.io.InputStream pInputStream)
                   throws java.io.IOException
The OutputConsumer must read the output of a process from the given InputStream.

Specified by:
consumeOutput in interface OutputConsumer
Throws:
java.io.IOException

consumeError

public void consumeError(java.io.InputStream pInputStream)
                  throws java.io.IOException
The ErrorConsumer must read the error of a process from the given InputStream.

Specified by:
consumeError in interface ErrorConsumer
Throws:
java.io.IOException

The im4java Library, Version 1.4.0

Released under the LGPL, (c) Bernhard Bablok 2008-2010
Homepage: http://im4java.sourceforge.net/