|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.calitha.io.StreamUtil
public final class StreamUtil
This utility class provides several convenience methods for working with input streams, output streams and random access files.
| Method Summary | |
|---|---|
static long |
blockReadToWrite(ReadWrapper in,
WriteWrapper out)
Copies all bytes from a ReadWrapper to a WriteWrapper object in blocks. |
static void |
closeInputStream(InputStream stream)
Try to close the input stream. |
static long |
copyRange(RandomAccessFile src,
long startSrc,
RandomAccessFile target,
long startTarget,
int size)
Copies a part of a source random access file to a target random access file. |
static long |
fileRangeToStream(OutputStream out,
RandomAccessFile raf,
long start,
int size)
Copies in blocks a part of a random access file to an output stream. |
static byte[] |
inStreamToByteArray(InputStream in)
Copies in blocks the bytes from an input stream to a new byte array |
static ByteArrayInputStream |
inStreamToByteInStream(InputStream in)
Copies in blocks the bytes from an input stream to a new byte array input stream. |
static ByteArrayOutputStream |
inStreamToByteOutStream(InputStream in)
Copies in blocks the bytes from a input stream to a new byte array output stream. |
static long |
inStreamToOutStream(InputStream in,
OutputStream out)
Copies in blocks the bytes from an input stream to and output stream. |
static long |
inStreamToRAF(InputStream in,
RandomAccessFile out)
Copies in blocks the bytes from an input stream to a random access file. |
static long |
rafToOutStream(RandomAccessFile in,
OutputStream out)
Copies in blocks the bytes from a random access file to a output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static long blockReadToWrite(ReadWrapper in,
WriteWrapper out)
throws IOException
Internally it means it can be used to copy from an InputStream or RandomAccessFile to an OutputStream or RandomAccessFile.
in - ReadWrapper objectout - WriteWrapper object
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static long inStreamToOutStream(InputStream in,
OutputStream out)
throws IOException
in - input streamout - output stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static long inStreamToRAF(InputStream in,
RandomAccessFile out)
throws IOException
in - input streamout - output stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static long rafToOutStream(RandomAccessFile in,
OutputStream out)
throws IOException
in - input streamout - output stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static ByteArrayOutputStream inStreamToByteOutStream(InputStream in)
throws IOException
in - input stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static byte[] inStreamToByteArray(InputStream in)
throws IOException
in - input stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static ByteArrayInputStream inStreamToByteInStream(InputStream in)
throws IOException
in - input stream
IOException - if an I/O error occurs
IllegalArgumentException - if an argument is null
public static long fileRangeToStream(OutputStream out,
RandomAccessFile raf,
long start,
int size)
throws IOException
out - output streamraf - random access file that is used as inputstart - start positionsize - size of the part being copied
IOException - if an I/O error occurs
IllegalArgumentException - if the out or raf argument is null
public static long copyRange(RandomAccessFile src,
long startSrc,
RandomAccessFile target,
long startTarget,
int size)
throws IOException
The source and target can be the same object. However in that case the two parts declared by startSrc, startTarget and size must not overlap.
src - source random access filestartSrc - start position for reading in the sourcetarget - target random access filestartTarget - start position for writing in the targetsize - total size of the part being copied
IOException - if an I/O error occurs, possibly because the parts
would overlap
IllegalArgumentException - if the source or target argument is nullpublic static void closeInputStream(InputStream stream)
Ignore any error if an I/O exception is thrown or if the stream is null.
stream - the input stream
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||