com.partnersoft.io
Class IOLib

java.lang.Object
  extended by com.partnersoft.io.IOLib

public class IOLib
extends java.lang.Object

General-purpose I/O routines.

Author:
Paul Reavis Copyright 2003 Partner Software, Inc.

Field Summary
static int BUFFER_SIZE
           
 
Constructor Summary
IOLib()
           
 
Method Summary
static long checksum(byte[] victim)
          Generates a checksum for the given byte array.
static long dataCopy(java.io.DataInput source, java.io.DataOutput sink, int howMany)
          Binary copies up to the given number of bytes from a DataInput object to an DataOutput object.
static long dataToStream(java.io.DataInput source, java.io.OutputStream sink, int howMany)
           
static long dataToStream(java.io.DataInput source, java.io.OutputStream sink, int howMany, java.security.MessageDigest digest)
          Binary copies up to the given number of bytes from a DataInput object to an output stream.
static long streamCopy(java.io.InputStream source, java.io.OutputStream sink)
          Binary copies bytes from an input stream to an output stream.
static long streamCopy(java.io.InputStream source, java.io.OutputStream sink, ActivityProgress progress, int progressLevel)
           
static long streamCopy(java.io.InputStream source, java.io.OutputStream sink, int howMany)
          Binary copies up to the given number of bytes from an input stream to an output stream.
static long streamCopy(java.io.InputStream source, java.io.OutputStream sink, int howMany, java.security.MessageDigest digest)
          Binary copies up to the given number of bytes from an input stream to an output stream.
static long streamCopyWithChecksum(java.io.InputStream source, java.io.OutputStream sink, int howMany)
          Binary copies up to the given number of bytes from an input stream to an output stream.
static long textCopy(java.io.Reader source, java.io.Writer sink)
          Copies text from a read to a writer.
static long textCopy(java.io.Reader source, java.io.Writer sink, ActivityProgress progress, int progressLevel)
           
static long textCopy(java.io.Reader source, java.io.Writer sink, int howMany)
          Binary copies up to the given number of bytes from an input stream to an output stream.
 
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
See Also:
Constant Field Values
Constructor Detail

IOLib

public IOLib()
Method Detail

streamCopy

public static long streamCopy(java.io.InputStream source,
                              java.io.OutputStream sink)
                       throws java.io.IOException
Binary copies bytes from an input stream to an output stream. The process is buffered, so you shouldn't need BufferedInput/OutputStreams. Flushes when it's finished, but does not close either stream. Returns the number of bytes copied.

Throws:
java.io.IOException

streamCopy

public static long streamCopy(java.io.InputStream source,
                              java.io.OutputStream sink,
                              ActivityProgress progress,
                              int progressLevel)
                       throws java.io.IOException
Throws:
java.io.IOException

streamCopy

public static long streamCopy(java.io.InputStream source,
                              java.io.OutputStream sink,
                              int howMany)
                       throws java.io.IOException
Binary copies up to the given number of bytes from an input stream to an output stream. The process is buffered, so you shouldn't need BufferedInput/OutputStreams. Flushes when it's finished, but does not close either stream. Throws an EOFExeption if there aren't enough bytes available to transfer the requested amount. Returns the total number of bytes copied.

Throws:
java.io.IOException

streamCopy

public static long streamCopy(java.io.InputStream source,
                              java.io.OutputStream sink,
                              int howMany,
                              java.security.MessageDigest digest)
                       throws java.io.IOException
Binary copies up to the given number of bytes from an input stream to an output stream. The process is buffered, so you shouldn't need BufferedInput/OutputStreams. Flushes when it's finished, but does not close either stream. Throws an EOFExeption if there aren't enough bytes available to transfer the requested amount. Returns the total number of bytes copied.

Throws:
java.io.IOException

textCopy

public static long textCopy(java.io.Reader source,
                            java.io.Writer sink)
                     throws java.io.IOException
Copies text from a read to a writer. The process is buffered, so you shouldn't need BufferedReader/BufferedWriter. Flushes when it's finished, but does not close either stream. Returns the number of bytes copied.

Throws:
java.io.IOException

textCopy

public static long textCopy(java.io.Reader source,
                            java.io.Writer sink,
                            ActivityProgress progress,
                            int progressLevel)
                     throws java.io.IOException
Throws:
java.io.IOException

textCopy

public static long textCopy(java.io.Reader source,
                            java.io.Writer sink,
                            int howMany)
                     throws java.io.IOException
Binary copies up to the given number of bytes from an input stream to an output stream. The process is buffered, so you shouldn't need BufferedInput/Writers. Flushes when it's finished, but does not close either stream. Throws an EOFExeption if there aren't enough bytes available to transfer the requested amount. Returns the total number of bytes copied.

Throws:
java.io.IOException

dataToStream

public static long dataToStream(java.io.DataInput source,
                                java.io.OutputStream sink,
                                int howMany)
                         throws java.io.IOException
Throws:
java.io.IOException

dataToStream

public static long dataToStream(java.io.DataInput source,
                                java.io.OutputStream sink,
                                int howMany,
                                java.security.MessageDigest digest)
                         throws java.io.IOException
Binary copies up to the given number of bytes from a DataInput object to an output stream. The process is buffered, so you shouldn't need BufferedInput/OutputStreams. Flushes when it's finished, but does not close either stream. Throws an EOFExeption if there aren't enough bytes available to transfer the requested amount. Returns the total number of bytes copied.

Throws:
java.io.IOException

streamCopyWithChecksum

public static long streamCopyWithChecksum(java.io.InputStream source,
                                          java.io.OutputStream sink,
                                          int howMany)
                                   throws java.io.IOException
Binary copies up to the given number of bytes from an input stream to an output stream. The process is buffered, so you shouldn't need BufferedInput/OutputStreams. Flushes when it's finished, but does not close either stream. Throws an EOFExeption if there aren't enough bytes available to transfer the requested amount. Returns the checksum of the bytes copied.

Throws:
java.io.IOException

dataCopy

public static long dataCopy(java.io.DataInput source,
                            java.io.DataOutput sink,
                            int howMany)
                     throws java.io.IOException
Binary copies up to the given number of bytes from a DataInput object to an DataOutput object. The process is buffered. Since DataOutput doesn't support closing or flushing, it does neither. Returns the total number of bytes copied.

Throws:
java.io.IOException

checksum

public static long checksum(byte[] victim)
                     throws java.io.IOException
Generates a checksum for the given byte array.

Throws:
java.io.IOException