org.equanda.util.io
Class StreamUtil

java.lang.Object
  extended by org.equanda.util.io.StreamUtil

public final class StreamUtil
extends Object

Utility code for handling streams.

Author:
Joachim Van der Auwera

Method Summary
static void copy(InputStream in, OutputStream out)
           
static String slurp(InputStream stream)
          Convert an inputstream to a string by reading the streams content.
static String slurp(InputStream stream, String encoding)
          Convert an inputstream to a string by reading the streams content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

slurp

public static String slurp(InputStream stream)
                    throws IOException
Convert an inputstream to a string by reading the streams content. Using UTF-8 character encoding. A newline is added at te end of the document if there was none.

Parameters:
stream - stream to convert
Returns:
string containing the streams content, ending in newline
Throws:
IOException - oops

slurp

public static String slurp(InputStream stream,
                           String encoding)
                    throws IOException
Convert an inputstream to a string by reading the streams content. A newline is added at te end of the document if there was none.

Parameters:
stream - stream to convert
encoding - character encoding to use for stream
Returns:
string containing the streams content, ending in newline
Throws:
IOException - oops

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Throws:
IOException


Copyright © 2007-2009. All Rights Reserved.