org.springframework.extensions.surf.util
Class DataUtil

java.lang.Object
  extended by org.springframework.extensions.surf.util.DataUtil

public class DataUtil
extends Object

A collection of useful static methods for working with input and output streams.

Author:
muzquiano

Constructor Summary
DataUtil()
           
 
Method Summary
static void copyStream(InputStream input, OutputStream output)
          Copy stream.
static int copyStream(InputStream in, OutputStream out, boolean closeStreams)
          Copy stream.
static ByteArrayOutputStream copyToByteArray(InputStream input, boolean closeInputStream)
          Copy to byte array.
static String copyToString(InputStream input, String encoding, boolean closeInputStream)
          Copy to string.
static byte[] toByteArray(InputStream input)
          To byte array.
static byte[] toByteArray(InputStream input, boolean closeStream)
          To byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataUtil

public DataUtil()
Method Detail

copyStream

public static void copyStream(InputStream input,
                              OutputStream output)
                       throws IOException
Copy stream.

Parameters:
input - the input
output - the output
Throws:
IOException - Signals that an I/O exception has occurred.

copyStream

public static int copyStream(InputStream in,
                             OutputStream out,
                             boolean closeStreams)
                      throws IOException
Copy stream.

Parameters:
in - the in
out - the out
closeStreams - the close streams
Returns:
the int
Throws:
IOException - Signals that an I/O exception has occurred.

toByteArray

public static byte[] toByteArray(InputStream input)
                          throws IOException
To byte array.

Parameters:
input - the input
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

toByteArray

public static byte[] toByteArray(InputStream input,
                                 boolean closeStream)
                          throws IOException
To byte array.

Parameters:
input - the input
closeStream - the close stream
Returns:
the byte[]
Throws:
IOException - Signals that an I/O exception has occurred.

copyToByteArray

public static ByteArrayOutputStream copyToByteArray(InputStream input,
                                                    boolean closeInputStream)
                                             throws IOException
Copy to byte array.

Parameters:
input - the input
closeInputStream - the close input stream
Returns:
the byte array output stream
Throws:
IOException - Signals that an I/O exception has occurred.

copyToString

public static String copyToString(InputStream input,
                                  String encoding,
                                  boolean closeInputStream)
                           throws IOException
Copy to string.

Parameters:
input - the input
closeInputStream - the close input stream
Returns:
the string
Throws:
IOException - Signals that an I/O exception has occurred.


Copyright © 2009 SpringSource, Inc. All Rights Reserved.