net.craftforge.commons.io
Class StreamUtils

java.lang.Object
  extended by net.craftforge.commons.io.StreamUtils

public class StreamUtils
extends Object

Stream Utils provide algorithms for standard stream operations.

Since:
29.08.11
Author:
Christian Bick

Constructor Summary
StreamUtils()
           
 
Method Summary
static Object getObjectFromXmlOutputStream(Class<?> clazz, ByteArrayOutputStream outputStream, String charset)
          Gets an object from an XML output stream using the given charset.
static InputStream getXmlInputStreamFromObject(Object object, String charset)
          Gets an XML input stream from an object using the given charset.
static String readStringFromInputStream(InputStream inputStream, String charset)
          Reads a string from an input stream using the given charset for decoding.
static String readStringFromInputStreamReader(InputStreamReader inputStreamReader)
          Reads a string from an input stream using the given input stream reader.
 
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

readStringFromInputStream

public static String readStringFromInputStream(InputStream inputStream,
                                               String charset)
                                        throws IOException
Reads a string from an input stream using the given charset for decoding.

Parameters:
inputStream - The input stream
charset - The charset
Returns:
The read string
Throws:
IOException - if the input stream cannot be read

readStringFromInputStreamReader

public static String readStringFromInputStreamReader(InputStreamReader inputStreamReader)
                                              throws IOException
Reads a string from an input stream using the given input stream reader.

Parameters:
inputStreamReader - The input stream reader
Returns:
The read string
Throws:
IOException - if the input stream cannot be read

getObjectFromXmlOutputStream

public static Object getObjectFromXmlOutputStream(Class<?> clazz,
                                                  ByteArrayOutputStream outputStream,
                                                  String charset)
Gets an object from an XML output stream using the given charset.

Parameters:
clazz - The object's class
outputStream - The XML output stream
charset - The charset
Returns:
The object

getXmlInputStreamFromObject

public static InputStream getXmlInputStreamFromObject(Object object,
                                                      String charset)
Gets an XML input stream from an object using the given charset.

Parameters:
object - The object
charset - The charset
Returns:
The XML input stream


Copyright © 2011. All Rights Reserved.