kiwi.util
Class StreamUtils

java.lang.Object
  extended bykiwi.util.StreamUtils

public final class StreamUtils
extends java.lang.Object

This class consists of several convenience routines for reading and writing streams. The methods are all static.

Since:
Kiwi 1.3.1
Author:
Mark Lindner, PING Software Group

Field Summary
static int blockSize
          The data transfer block size.
 
Constructor Summary
StreamUtils()
           
 
Method Summary
private static java.io.ByteArrayOutputStream readStream(java.io.InputStream input)
           
static byte[] readStreamToByteArray(java.io.InputStream input)
          Read all of the data from a stream, returning the contents as a byte array.
static java.io.OutputStream readStreamToStream(java.io.InputStream input, java.io.OutputStream output)
          Read all of the data from a stream, writing it to another stream.
static java.lang.String readStreamToString(java.io.InputStream input)
          Read all of the data from a stream, returning the contents as a String.
static void writeStringToStream(java.lang.String s, java.io.OutputStream output)
          Write a string to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blockSize

public static final int blockSize
The data transfer block size.

See Also:
Constant Field Values
Constructor Detail

StreamUtils

public StreamUtils()
Method Detail

readStreamToStream

public static final java.io.OutputStream readStreamToStream(java.io.InputStream input,
                                                            java.io.OutputStream output)
                                                     throws java.io.IOException
Read all of the data from a stream, writing it to another stream. Reads data from the input stream and writes it to the output stream, until no more data is available.

Parameters:
input - The input stream.
output - The output stream.
Throws:
java.io.IOException - If an error occurred while reading from the stream.

readStreamToString

public static final java.lang.String readStreamToString(java.io.InputStream input)
                                                 throws java.io.IOException
Read all of the data from a stream, returning the contents as a String. Note that this method is not unicode-aware.

Parameters:
input - The stream to read from.
Returns:
The contents of the stream, as a String.
Throws:
java.io.IOException - If an error occurred while reading from the stream.

writeStringToStream

public static final void writeStringToStream(java.lang.String s,
                                             java.io.OutputStream output)
                                      throws java.io.IOException
Write a string to a stream. Note that this method is not unicode-aware.

Parameters:
s - The string to write.
output - The stream to write it to.
Throws:
java.io.IOException - If an error occurred while writing to the stream.

readStreamToByteArray

public static final byte[] readStreamToByteArray(java.io.InputStream input)
                                          throws java.io.IOException
Read all of the data from a stream, returning the contents as a byte array.

Parameters:
input - The stream to read from.
Returns:
The contents of the stream, as a byte array.
Throws:
java.io.IOException - If an error occurred while reading from the stream.

readStream

private static final java.io.ByteArrayOutputStream readStream(java.io.InputStream input)
                                                       throws java.io.IOException
Throws:
java.io.IOException