org.strutsme.common.io
Class StreamTools

java.lang.Object
  extended by org.strutsme.common.io.StreamTools

public final class StreamTools
extends java.lang.Object

Contains methods to read a string from a stream and write a string to a stream.

The reason for the added magic test is that it enables a fast finding of mistakes. Otherwise for example an OutOfMemoryError is much harder to diagnose.

Author:
rfalke

Constructor Summary
StreamTools()
           
 
Method Summary
static java.lang.String readStreamData(java.io.InputStream is)
          Reads a string from the given stream.
static void writeStreamData(java.io.OutputStream os, java.lang.String data)
          Writes a string into the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamTools

public StreamTools()
Method Detail

readStreamData

public static java.lang.String readStreamData(java.io.InputStream is)
                                       throws java.io.IOException
Reads a string from the given stream.

Parameters:
is - the stream to read from
Returns:
the string
Throws:
java.io.IOException - in case of an error in the underlying stream

writeStreamData

public static void writeStreamData(java.io.OutputStream os,
                                   java.lang.String data)
                            throws java.io.IOException
Writes a string into the given stream.

Parameters:
os - the stream to write into
data - the string
Throws:
java.io.IOException - in case of an error in the underlying stream