at.gv.egovernment.moa.util
Class StreamUtils

java.lang.Object
  |
  +--at.gv.egovernment.moa.util.StreamUtils

public class StreamUtils
extends Object

Utility methods for streams.

Version:
$Id$
Author:
Patrick Peck

Constructor Summary
StreamUtils()
           
 
Method Summary
static boolean compareStreams(InputStream is1, InputStream is2)
          Compare the contents of two InputStreams.
static byte[] readStream(InputStream in)
          Reads a byte array from a stream.
static String readStream(InputStream in, String encoding)
          Reads a String from a stream, using given encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamUtils

public StreamUtils()
Method Detail

compareStreams

public static boolean compareStreams(InputStream is1,
                                     InputStream is2)
                              throws IOException
Compare the contents of two InputStreams.
Parameters:
is1 - The 1st InputStream to compare.
is2 - The 2nd InputStream to compare.
Returns:
boolean true, if both streams contain the exactly the same content, false otherwise.
Throws:
IOException - An error occurred reading one of the streams.

readStream

public static byte[] readStream(InputStream in)
                         throws IOException
Reads a byte array from a stream.
Parameters:
in - The InputStream to read.
Returns:
The bytes contained in the given InputStream.
Throws:
IOException - on any exception thrown

readStream

public static String readStream(InputStream in,
                                String encoding)
                         throws IOException
Reads a String from a stream, using given encoding.
Parameters:
in - The InputStream to read.
encoding - The character encoding to use for converting the bytes of the InputStream into a String.
Returns:
The content of the given InputStream converted into a String.
Throws:
IOException - on any exception thrown