net.sourceforge.jaulp.io
Class StreamUtils

java.lang.Object
  extended by net.sourceforge.jaulp.io.StreamUtils
All Implemented Interfaces:
java.io.Serializable

public class StreamUtils
extends java.lang.Object
implements java.io.Serializable

Utility class for input/output operations.

Version:
1.0
Author:
Asterios Raptis
See Also:
Serialized Form

Constructor Summary
StreamUtils()
           
 
Method Summary
static void close(java.io.InputStream in)
          Closes the given InputStream.
static void close(java.io.OutputStream out)
          Closes the given OutputStream.
static void close(java.io.Reader reader)
          Closes the given Reader.
static void close(java.io.Writer writer)
          Closes the given Writer.
static boolean closeInputStream(java.io.InputStream in)
          Closes the given InputStream.
static boolean closeOutputStream(java.io.OutputStream out)
          Closes the given OutputStream.
static boolean closeReader(java.io.Reader reader)
          Closes the given Reader.
static boolean closeWriter(java.io.Writer writer)
          Closes the given Writer.
static byte[] getByteArray(java.io.InputStream in)
          Returns the given InputStream as a byte array.
static byte[] getByteArray(java.io.InputStream in, java.io.ByteArrayOutputStream os)
          Gets the byte array.
static java.lang.String getPackagePath(java.lang.Class clazz)
          Deprecated. Use instead ResourceUtils.getPackagePath(Class).
static long getSerialVersionUID(java.lang.Class clazz)
          Gets the SerialVersionUID from the given Class.
static void writeInputStreamToOutputStream(java.io.InputStream inputStream, java.io.OutputStream outputStream, boolean closeStream)
          The Method writeInputStreamToOutputStream(InputStream, OutputStream, boolean) writes to the given OutputStream from an opened InputStream.
 
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

close

public static void close(java.io.InputStream in)
                  throws java.io.IOException
Closes the given InputStream.

Parameters:
in - The InputStream to close.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

close

public static void close(java.io.OutputStream out)
                  throws java.io.IOException
Closes the given OutputStream.

Parameters:
out - The OutputStream to close.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

close

public static void close(java.io.Reader reader)
                  throws java.io.IOException
Closes the given Reader.

Parameters:
reader - The Reader to close.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

close

public static void close(java.io.Writer writer)
                  throws java.io.IOException
Closes the given Writer.

Parameters:
writer - The Writer to close.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

closeInputStream

public static boolean closeInputStream(java.io.InputStream in)
Closes the given InputStream.

Parameters:
in - The InputStream to close.
Returns:
Returns true if the OutputStream is closed otherwise false.

closeOutputStream

public static boolean closeOutputStream(java.io.OutputStream out)
Closes the given OutputStream.

Parameters:
out - The OutputStream to close.
Returns:
Returns true if the OutputStream is closed otherwise false.

closeReader

public static boolean closeReader(java.io.Reader reader)
Closes the given Reader.

Parameters:
reader - The Reader to close.
Returns:
Returns true if the Reader is closed otherwise false.

closeWriter

public static boolean closeWriter(java.io.Writer writer)
Closes the given Writer.

Parameters:
writer - The Writer to close.
Returns:
Returns true if the Writer is closed otherwise false.

getByteArray

public static byte[] getByteArray(java.io.InputStream in)
                           throws java.io.IOException
Returns the given InputStream as a byte array.

Parameters:
in - The InputStream.
Returns:
Returns the given InputStream as a byte array.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getByteArray

public static byte[] getByteArray(java.io.InputStream in,
                                  java.io.ByteArrayOutputStream os)
                           throws java.io.IOException
Gets the byte array.

Parameters:
in - The InputStream.
os - The ByteArrayOutputStream.
Returns:
the byte array
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

getPackagePath

@Deprecated
public static java.lang.String getPackagePath(java.lang.Class clazz)
Deprecated. Use instead ResourceUtils.getPackagePath(Class).

Gets the package as in manner like the path.

Parameters:
clazz - The Class.
Returns:
's the Path from the package.

getSerialVersionUID

public static long getSerialVersionUID(java.lang.Class clazz)
Gets the SerialVersionUID from the given Class.

Parameters:
clazz - The class
Returns:
the serial version uid

writeInputStreamToOutputStream

public static void writeInputStreamToOutputStream(java.io.InputStream inputStream,
                                                  java.io.OutputStream outputStream,
                                                  boolean closeStream)
                                           throws java.io.IOException
The Method writeInputStreamToOutputStream(InputStream, OutputStream, boolean) writes to the given OutputStream from an opened InputStream.

Parameters:
inputStream - The opened InputStream.
outputStream - The opened OutputStream.
closeStream - If true then close the outputStream otherwise keep open.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.


Copyright © 2010. All Rights Reserved.