com.hammurapi.util
Class Pumper

java.lang.Object
  extended by com.hammurapi.util.Pumper
All Implemented Interfaces:
Callable<Long>

public class Pumper
extends Object
implements Callable<Long>

Copies all data from an input stream to an output stream.

Version:
$Revision: 1.3 $
Author:
Pavel Vlasov

Constructor Summary
Pumper(InputStream is, OutputStream os, boolean closeStreams)
          Create a new pumper.
Pumper(Reader reader, Writer writer, boolean closeStreams)
          Create a new pumper.
 
Method Summary
 Long call()
          Copies data from the input stream to the output stream.
static long pump(InputStream in, OutputStream out, boolean closeStreams)
          Copies data from the input stream to the output stream.
static long pump(Reader in, Writer out, boolean closeStreams)
          Copies data from the reader to the writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pumper

public Pumper(InputStream is,
              OutputStream os,
              boolean closeStreams)
Create a new pumper.

Parameters:
is - input stream to read data from
os - output stream to write data to.

Pumper

public Pumper(Reader reader,
              Writer writer,
              boolean closeStreams)
Create a new pumper.

Parameters:
reader - Reader to read data from
writer - Writer to write data to.
Method Detail

call

public Long call()
          throws Exception
Copies data from the input stream to the output stream. Terminates as soon as the input stream is closed or an error occurs.

Specified by:
call in interface Callable<Long>
Throws:
Exception

pump

public static long pump(InputStream in,
                        OutputStream out,
                        boolean closeStreams)
                 throws IOException
Copies data from the input stream to the output stream.

Throws:
IOException

pump

public static long pump(Reader in,
                        Writer out,
                        boolean closeStreams)
                 throws IOException
Copies data from the reader to the writer.

Throws:
IOException