org.iges.util
Class Spooler

java.lang.Object
  |
  +--org.iges.util.Spooler

public class Spooler
extends java.lang.Object

A collection of methods that efficiently spool data from a finite-length source to a sink.


Constructor Summary
Spooler()
           
 
Method Summary
static long spool(java.io.InputStream in, java.io.OutputStream out)
          Spools byte data from an InputStream to an OutputStream until the InputStream is exhausted.
static long spool(java.io.InputStream in, java.io.OutputStream out, byte[] buf)
          Spools byte data from an InputStream to an OutputStream until the InputStream is exhausted.
static long spool(long totalBytesToWrite, java.io.InputStream in, java.io.OutputStream out, byte[] buf)
          Spools a fixed quantity of byte data from an InputStream to an OutputStream.
static long spool(java.io.Reader r, java.io.Writer w)
          Spools character data from a Reader to a Writer until the Reader is exhausted.
static long spool(java.io.Reader r, java.io.Writer w, char[] buf)
          Spools character data from a Reader to a Writer until the Reader is exhausted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Spooler

public Spooler()
Method Detail

spool

public static long spool(java.io.Reader r,
                         java.io.Writer w)
                  throws java.io.IOException
Spools character data from a Reader to a Writer until the Reader is exhausted.

Warning: if called on a stream with unlimited length (such as a network socket) this method will not return until the stream is closed. A buffer of 1024 characters is used for read and write operations.

Throws:
java.io.IOException - If an I/O error occurs.

spool

public static long spool(java.io.Reader r,
                         java.io.Writer w,
                         char[] buf)
                  throws java.io.IOException
Spools character data from a Reader to a Writer until the Reader is exhausted.

Warning: if called on a stream with unlimited length (such as a network socket) this method will not return until the stream is closed.

Throws:
java.io.IOException - If an I/O error occurs.

spool

public static long spool(java.io.InputStream in,
                         java.io.OutputStream out)
                  throws java.io.IOException
Spools byte data from an InputStream to an OutputStream until the InputStream is exhausted.

A buffer of 1024 bytes is used for read and write operations.

Warning: if called on a stream with unlimited length (such as a network socket) this method will not return until the stream is closed.

Throws:
java.io.IOException - If an I/O error occurs.

spool

public static long spool(java.io.InputStream in,
                         java.io.OutputStream out,
                         byte[] buf)
                  throws java.io.IOException
Spools byte data from an InputStream to an OutputStream until the InputStream is exhausted.

Warning: if called on a stream with unlimited length (such as a network socket) this method will not return until the stream is closed.

Throws:
java.io.IOException - If an I/O error occurs.
java.lang.IllegalArgumentException - If bufferSize is <= 0.

spool

public static long spool(long totalBytesToWrite,
                         java.io.InputStream in,
                         java.io.OutputStream out,
                         byte[] buf)
                  throws java.io.IOException
Spools a fixed quantity of byte data from an InputStream to an OutputStream.

Parameters:
totalBytesToWrite - The number of bytes that should be read.
Throws:
java.io.IOException - If an I/O error occurs, or the InputStream returns EOF before totalBytesToWrite bytes have been read.