|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.portal.common.io.IOTools
public class IOTools
IO tools.
| Field Summary | |
|---|---|
static org.apache.log4j.Logger |
log
The logger. |
| Constructor Summary | |
|---|---|
IOTools()
|
|
| Method Summary | ||
|---|---|---|
static
|
clone(S serializable)
Clone an object implementing the Serializable interface. |
|
static
|
clone(S serializable,
java.lang.ClassLoader classLoader)
Clone an object implementing the Serializable interface. |
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
|
|
static void |
copy(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize)
Pipe an incoming stream in an outcoming stream until no bytes is available from the input stream. |
|
static void |
copy(java.io.Reader reader,
java.io.Writer writer)
Pipe an input stream in an output stream. |
|
static void |
copy(java.io.Reader reader,
java.io.Writer writer,
int bufferSize)
Pipe an incoming stream in an outcoming stream. |
|
static byte[] |
getBytes(java.io.InputStream in)
|
|
static byte[] |
getBytes(java.io.InputStream in,
int bufferSize)
Get the bytes from the provided input stream. |
|
static java.io.BufferedInputStream |
safeBufferedWrapper(java.io.InputStream in)
Check that the provided input stream is buffered. |
|
static java.io.BufferedOutputStream |
safeBufferedWrapper(java.io.OutputStream out)
Check that the provided output stream is buffered. |
|
static void |
safeClose(java.io.Closeable out)
Attempt to close an Closeable object. |
|
static void |
safeClose(java.lang.Object closable)
Attempt to close an object. |
|
static byte[] |
serialize(java.io.Serializable serializable)
|
|
static
|
serialize(Serialization<T> serialization,
SerializationFilter filter,
T t)
|
|
static
|
serialize(Serialization<T> serialization,
T t)
|
|
static java.io.Serializable |
unserialize(byte[] bytes)
Unserialize the bytes into an object. |
|
static java.io.Serializable |
unserialize(byte[] bytes,
java.lang.ClassLoader classLoader)
Unserialize the bytes into an object. |
|
static
|
unserialize(Serialization<T> serialization,
byte[] bytes)
|
|
static
|
unserialize(Serialization<T> serialization,
SerializationFilter filter,
byte[] bytes)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final org.apache.log4j.Logger log
| Constructor Detail |
|---|
public IOTools()
| Method Detail |
|---|
public static void safeClose(java.lang.Object closable)
Attempt to close an object. Null argument value is authorized and no operation will be performed in that use case.
It will try to obtain a close() method by reflection and it
will be invoked only if the method is public and not static. If the method is called, any Error
or RuntimeException will be rethrown, any other kind of throwable will not be rethrown in any form.
closable - the object to closepublic static void safeClose(java.io.Closeable out)
Attempt to close an Closeable object. Null argument value is authorized and no operation will be performed in that
use case. IOException thrown are logged using the error level but not propagated.
out - the stream to close
public static byte[] getBytes(java.io.InputStream in)
throws java.io.IOException,
java.lang.IllegalArgumentException
in - the input stream
java.io.IOException
java.lang.IllegalArgumentException - if the input stream is nullgetBytes(java.io.InputStream, int)
public static byte[] getBytes(java.io.InputStream in,
int bufferSize)
throws java.io.IOException,
java.lang.IllegalArgumentException
in - the input streambufferSize - the buffer size used to copy the bytes
java.io.IOException
java.lang.IllegalArgumentException - if the input stream is null or the buffer size < 1
public static void copy(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - the incoming streamout - the outcoming stream
java.lang.IllegalArgumentException - if an argument is null
java.io.IOExceptioncopy(java.io.InputStream, java.io.OutputStream, int)
public static void copy(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize)
throws java.io.IOException
in - the incoming streamout - the outcoming streambufferSize - the buffer size
java.lang.IllegalArgumentException - if bufferSize < 1 or an argument is null
java.io.IOException
public static void copy(java.io.Reader reader,
java.io.Writer writer)
throws java.io.IOException
reader - the incoming readerwriter - the outcoming writer
java.lang.IllegalArgumentException - if an argument is null
java.io.IOException
public static void copy(java.io.Reader reader,
java.io.Writer writer,
int bufferSize)
throws java.io.IOException
reader - the incoming readerwriter - the outcoming writerbufferSize - the buffer size
java.lang.IllegalArgumentException - if bufferSize < 1 or an argument is null
java.io.IOException
public static <S extends java.io.Serializable> S clone(S serializable)
throws java.lang.IllegalArgumentException,
java.io.IOException
Serializable interface.
serializable - the serializable object to clone
java.lang.IllegalArgumentException - if the serializable object is null
java.io.IOException - any IOException
public static <S extends java.io.Serializable> S clone(S serializable,
java.lang.ClassLoader classLoader)
throws java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.ClassNotFoundException
Serializable interface. The specified classloader will be used
to perform the unserialization. If no classloader is specified and the object is not null then the classloader
used is the one returned by serializable.getClass().getClassLoader().
serializable - the serializable object to clone
java.lang.IllegalArgumentException - if the serializable object is null
java.io.IOException - any IOException
java.lang.ClassNotFoundException
public static byte[] serialize(java.io.Serializable serializable)
throws java.lang.IllegalArgumentException,
java.io.IOException
java.lang.IllegalArgumentException
java.io.IOException
public static java.io.Serializable unserialize(byte[] bytes)
throws java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.ClassNotFoundException
bytes - the bytes to unserialize
java.lang.IllegalArgumentException - if the byte array is null
java.io.IOException - any IOException
java.lang.ClassNotFoundException - any ClassNotFoundException
public static java.io.Serializable unserialize(byte[] bytes,
java.lang.ClassLoader classLoader)
throws java.lang.IllegalArgumentException,
java.io.IOException,
java.lang.ClassNotFoundException
bytes - the bytes to unserializeclassLoader - the classloader
java.lang.IllegalArgumentException - if the byte array is null
java.io.IOException - any IOException
java.lang.ClassNotFoundException - any ClassNotFoundException
public static <T> byte[] serialize(Serialization<T> serialization,
T t)
public static <T> byte[] serialize(Serialization<T> serialization,
SerializationFilter filter,
T t)
public static <T> T unserialize(Serialization<T> serialization,
byte[] bytes)
public static <T> T unserialize(Serialization<T> serialization,
SerializationFilter filter,
byte[] bytes)
public static java.io.BufferedInputStream safeBufferedWrapper(java.io.InputStream in)
BufferedInputStream
no operation will be performed, otherwise a instance of BufferedInputStream will be created and returned.
If the provided argument is null, the null value is returned.
in - the stream
public static java.io.BufferedOutputStream safeBufferedWrapper(java.io.OutputStream out)
BufferedOutputStream
no operation will be performed, otherwise a instance of BufferedOutputStream will be created and returned.
If the provided argument is null, the null value is returned.
out - the stream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||