|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.support.io.StreamUtil
public final class StreamUtil
This class contains static utility methods for working with streams.
Method Summary | |
---|---|
static long |
copyChannels(ReadableByteChannel rbc,
WritableByteChannel wbc,
int bufSize)
Copy binary data read from the readable byte channel to the writable byte channel. |
static long |
copyChannels(ReadableByteChannel rbc,
WritableByteChannel wbc,
int bufSize,
long noToCopy)
Copy binary data read from the readable byte channel to the writable byte channel. |
static long |
copyStreams(InputStream is,
OutputStream os,
int bufSize)
Copy data read from the input stream to the output stream. |
static long |
copyStreams(InputStream is,
OutputStream os,
int bufSize,
long noToCopy)
Copy data read from the input stream to the output stream. |
static long |
copyStreams(Reader r,
Writer w,
int bufSize)
Copy character data from the reader to the writer. |
static long |
copyStreams(Reader r,
Writer w,
int bufSize,
long noToCopy)
Copy data read from the character reader to the character writer. |
static long |
getSizeOfDataInStream(InputStream is,
int bufSize)
Calculate the size of the data that can be read from the stream. |
static byte[] |
readChannelFully(ReadableByteChannel c,
int bufSize)
Read the contents of the channel into a byte array. |
static byte[] |
readStreamFully(InputStream is,
int bufSize)
Read the contents of the stream into a byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static long copyStreams(InputStream is, OutputStream os, int bufSize, long noToCopy) throws WrappedIOException
bufSize
bytes long. No
more than noToCopy
bytes are copied, even if there are more bytes
available in the InputStream
.
is
- The input stream. Not closed after copying.os
- The output stream. Not closed after copying.bufSize
- The size of the data buffer. If writing to a file, it is
recommended that its file system's buffer size is used.noToCopy
- The maximum amount of bytes to copy. Set this to -1
(or call copyStreams(InputStream, OutputStream, int)
) to
copy all available data.
WrappedIOException
- On errors.copyStreams(InputStream, OutputStream, int)
,
copyStreams(Reader, Writer, int, long)
public static long copyStreams(InputStream is, OutputStream os, int bufSize) throws WrappedIOException
is
- The input stream. Not closed after copying.os
- The output stream. Not closed after copying.bufSize
- The size of the data buffer. If writing to a file, it is
recommended that its file system's buffer size is used.
WrappedIOException
- On errorscopyStreams(InputStream, OutputStream, int, long)
,
copyStreams(Reader, Writer, int)
public static long copyStreams(Reader r, Writer w, int bufSize, long noToCopy) throws WrappedIOException
bufSize
characters long. No more than noToCopy
characters are copied,
even if there are more characters available in r
r
- The reader to read character data from. Not closed after
copying.w
- The writer to write character data to. Not closed after copying.bufSize
- The number of characters in the temporary data buffer. If
writing to a file, it is recommended that its file system's buffer size
is used.noToCopy
- The maximum number of characters to copy. If this is set
to -1
(or if copyStreams(Reader, Writer, int)
is
called), all available characters in r
are copied.
WrappedIOException
- On errorscopyStreams(Reader, Writer, int)
,
copyStreams(InputStream, OutputStream, int, long)
public static long copyStreams(Reader r, Writer w, int bufSize) throws WrappedIOException
r
- The reader to read character data from. Not closed after
copying.w
- The writer to write character data from. Not closed after
copying.bufSize
- The size of the temporary data buffer. If writing to a
file, it is recommended that its file system's buffer size is used.
WrappedIOException
- On errorspublic static long copyChannels(ReadableByteChannel rbc, WritableByteChannel wbc, int bufSize, long noToCopy) throws WrappedIOException
bufSize
bytes. No more than noToCopy
bytes are copied, even if
there are more bytes available in rbc
.
rbc
- The readable byte channel to read data from. The channel is
not closed by this method.wbc
- The writable byte channel to write data to. The channel is not
closed by this method.bufSize
- The size of the temporary data buffer. If writing to a
file, it is recommended that its file system's buffer size is used.noToCopy
- The maximum number of bytes to copy. If this is set to
-1
(or if
copyChannels(ReadableByteChannel, WritableByteChannel, int)
is
called), all available data in rbc
is copied.
WrappedIOException
- On errorspublic static long copyChannels(ReadableByteChannel rbc, WritableByteChannel wbc, int bufSize) throws WrappedIOException
bufSize
bytes.
rbc
- The readable byte channel to read data from. The channel is
not closed by this method.wbc
- The writable byte channel to write data to. The channel is not
closed by this method.bufSize
- The size of the temporary data buffer. If writing to a
file, it is recommended that its file system's buffer size is used.
WrappedIOException
- On errorscopyChannels(ReadableByteChannel, WritableByteChannel, int, long)
public static long getSizeOfDataInStream(InputStream is, int bufSize) throws WrappedIOException
is
- The input stream. Not closed by this method.bufSize
- The size of temporary data buffers. If reading from a
file, it is recommended that the file's file system's buffer size is
used.
WrappedIOException
- On errors.public static byte[] readStreamFully(InputStream is, int bufSize) throws WrappedIOException, IllegalArgumentException
is
- The stream to read from. Not closed by this method.bufSize
- The size of temporary buffers. If reading from a file, it
is recommended that its file system's buffer size is used.
WrappedIOException
- On I/O errors.
IllegalArgumentException
- If the buffer size is 0
or less.readChannelFully(ReadableByteChannel, int)
public static byte[] readChannelFully(ReadableByteChannel c, int bufSize) throws WrappedIOException, IllegalArgumentException
c
- The channel to read from. Not closed by this method.bufSize
- The size of temporary buffers. If reading from a file, it
is recommended that its file system's buffer size is used.
WrappedIOException
- On I/O errors.
IllegalArgumentException
- If the buffer size is 0
or less.readStreamFully(InputStream, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |