|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.larsan.urd.util.IOUtils
A collection of static methods for stream and channel utilities. All buffered operations uses
a buffer of size DEFAULT_BUFFER_SIZE (2048 bytes) if not specified.
| Field Summary | |
static int |
DEFAULT_BUFFER_SIZE
Default buffer size for buffered operation in this class, 2048 bytes. |
| Constructor Summary | |
IOUtils()
|
|
| Method Summary | |
static byte[] |
toByteArray(java.nio.channels.FileChannel channel)
Read a complete channel to a byte array. |
static byte[] |
toByteArray(java.io.InputStream in)
Read a complete stream to a byte array. |
static byte[] |
toByteArray(java.io.InputStream in,
int bufferSize)
Read a complete input stream to a byte array with a non-default buffer size. |
static void |
toFile(java.io.File file,
java.io.InputStream stream)
Write the content of an input stream to a file. |
static void |
toFile(java.io.File file,
java.lang.String string)
Write the content of a string to a file. |
static java.lang.String |
toString(java.io.File file)
Read a complete file to a string. |
static java.lang.String |
toString(java.io.InputStream in)
Read an complete input stream to a string. |
static long |
transfer(java.io.InputStream in,
java.io.OutputStream out)
Transfer bytes from one stream to another. |
static long |
transfer(java.io.InputStream in,
java.io.OutputStream out,
int buffSize)
Transfer bytes from one stream to another. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_BUFFER_SIZE
| Constructor Detail |
public IOUtils()
| Method Detail |
public static long transfer(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - Input stream to read fromout - Output stream to write to
java.io.IOException - If an IO error occurs
public static long transfer(java.io.InputStream in,
java.io.OutputStream out,
int buffSize)
throws java.io.IOException
in - Input stream to read fromout - Output stream to write tobuffSize - Buffer size
java.io.IOException - If an IO error occurs
public static byte[] toByteArray(java.nio.channels.FileChannel channel)
throws java.io.IOException
channel - File channel to read to byte array
java.io.IOException - If an IO error occur
public static byte[] toByteArray(java.io.InputStream in)
throws java.io.IOException
in - Input stream to read from.
java.io.IOException - If an IO error occur
public static byte[] toByteArray(java.io.InputStream in,
int bufferSize)
throws java.io.IOException
in - Input stream to read frombufferSize - Size of operation byte buffer
java.io.IOException - If an IO error occur
public static java.lang.String toString(java.io.File file)
throws java.io.IOException
file - File to read from
java.io.IOException - If an IO error occur
public static java.lang.String toString(java.io.InputStream in)
throws java.io.IOException
in - Input stream to read from
java.io.IOException - If an IO error occur
public static void toFile(java.io.File file,
java.lang.String string)
throws java.io.IOException
file - File to write the string tostring - String content
java.io.IOException - If an IO error occur
public static void toFile(java.io.File file,
java.io.InputStream stream)
throws java.io.IOException
file - File to write the string tostream - Stream to write
java.io.IOException - If an IO error occur
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||