Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboStreamHelper

java.lang.Object
 |
 +--com.sssw.fw.util.EboStreamHelper

public class EboStreamHelper
extends Object

Useful utility methods to handle frequently duplicated actions on Streams


Constructor Summary
EboStreamHelper()
           
 
Method Summary
static void copyOut(InputStream in, OutputStream out)
          Copy the contents of the InputStream to the OutputStream
static void copyOut(Reader in, Writer out)
          Copy the contents of the Reader to the Writer
static InputStream getInputStream(String s)
          Create an InputStream for the given String.
static String getString(InputStream in)
          Read the contents of the InputStream and return it as a String
static byte[] readFully(File f)
          Returns the contents of the file as a byte array
static byte[] readFully(InputStream in)
          Returns the contents of the InputStream as a byte array.
static boolean shouldBuffer(InputStream is)
          Determine whether or not it will help to wrap the specified InputStream in a BufferedInputStream.
static boolean shouldBuffer(OutputStream is)
          Determine whether or not it will help to wrap the specified OutputStream in a BufferedOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EboStreamHelper

public EboStreamHelper()
Method Detail

readFully

public static byte[] readFully(File f)
                        throws IOException
Returns the contents of the file as a byte array

readFully

public static byte[] readFully(InputStream in)
                        throws Exception
Returns the contents of the InputStream as a byte array. Does not close the InputStream.

getInputStream

public static InputStream getInputStream(String s)
Create an InputStream for the given String.
Parameters:
s - The string used as input to a stream.
Returns:
An InputStream object

copyOut

public static void copyOut(InputStream in,
                           OutputStream out)
                    throws IOException
Copy the contents of the InputStream to the OutputStream
Parameters:
in - source InputStream of copy request
out - destination OutputStream of copy request
Throws:
com.sssw.fw.util.IOException -  

copyOut

public static void copyOut(Reader in,
                           Writer out)
                    throws IOException
Copy the contents of the Reader to the Writer
Parameters:
in - source Reader of copy request
out - destination Writer of copy request
Throws:
com.sssw.fw.util.IOException -  

getString

public static String getString(InputStream in)
                        throws IOException
Read the contents of the InputStream and return it as a String
Parameters:
in - source InputStream of copy request
Returns:
String value of input content, or null if empty input stream
Throws:
com.sssw.fw.util.IOException -  

shouldBuffer

public static boolean shouldBuffer(InputStream is)
Determine whether or not it will help to wrap the specified InputStream in a BufferedInputStream. For the present, we don't buffer streams that are already bufferred, or streams from ByteBuffers, or streams from Strings.
Parameters:
is - Input stream
Returns:
True iff we think it will help performance to add a buffer

shouldBuffer

public static boolean shouldBuffer(OutputStream is)
Determine whether or not it will help to wrap the specified OutputStream in a BufferedOutputStream. For the present, we don't buffer streams that are already bufferred, or streams from EboByteBuffers, or streams from Strings.
Parameters:
is - Output stream
Returns:
True iff we think it will help performance to add a buffer

Novell exteNd
Director 5.2 API