|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jagatoo.util.streams.StreamUtils
public class StreamUtils
Contains static utility methods for Stream.
Field Summary | |
---|---|
static int |
TRANSFER_BUFFER_SIZE
|
Method Summary | |
---|---|
static byte[] |
buildByteArray(java.io.InputStream in)
This calls buildByteArray(InputStream, int) with an initialSize
of in.available(). |
static byte[] |
buildByteArray(java.io.InputStream in,
int initialSize)
Builds a byte-array from the given InputStream. |
static java.lang.Boolean |
closeReader(java.io.Reader r)
Closes the passed reader if non null ignoring theoretically irrelevant IOException. |
static java.lang.Boolean |
closeStream(java.io.InputStream s)
Closes the passed stream if non null ignoring theoretically irrelevant IOException. |
static java.lang.Boolean |
closeStream(java.io.OutputStream s)
Closes the passed stream if non null ignoring theoretically irrelevant IOException. |
static java.lang.Boolean |
closeWriter(java.io.Writer w)
Closes the passed writer if non null ignoring theoretically irrelevant IOException. |
static java.lang.Boolean |
flushStream(java.io.OutputStream s)
Flushes the given stream, if it is non null and ignores a rarely possible IOException . |
static java.lang.Boolean |
flushWriter(java.io.Writer w)
Flushes the given writer, if it is non null and ignores a rarely possible IOException . |
static byte[] |
getBytesFromStream(java.io.InputStream in)
Copies all bytes from the given InputStream into a new byte array. |
static byte[] |
getBytesFromStream(java.io.InputStream in,
boolean closeIn)
Copies all bytes from the given InputStream into a new byte array. |
static java.lang.String |
getStringFromStream(java.io.InputStream in)
Copies all bytes from the given InputStream into a new String. |
static java.lang.String |
getStringFromStream(java.io.InputStream in,
boolean closeIn)
Copies all bytes from the given InputStream into a new String. |
static byte |
readByte(java.io.BufferedInputStream in)
Reads one byte from the InputStream. |
static byte |
readByte(java.io.InputStream in)
Reads one byte from the InputStream. |
static void |
readBytes(java.io.BufferedInputStream in,
int bytesToRead,
byte[] buffer,
int bufferOffset)
Reads bytesToRead bytes from the stream. |
static void |
readBytes(java.io.InputStream in,
int bytesToRead,
byte[] buffer,
int bufferOffset)
Reads bytesToRead bytes from the stream. |
static java.lang.String |
readCString(java.io.InputStream in,
int maxLength,
boolean alwaysReadMaxLength)
Reads a String from the InputStream. |
static int |
readInt(java.io.BufferedInputStream in)
Reads one (signed) int from the stream. |
static int |
readInt(java.io.InputStream in)
Reads one (signed) int from the stream. |
static short |
readShort(java.io.BufferedInputStream in)
Reads two bytes from the InputStream stored in a short-value. |
static short |
readShort(java.io.InputStream in)
Reads two bytes from the InputStream stored in a short-value. |
static int |
readSwappedInt(java.io.BufferedInputStream in)
Reads one (signed) int from the stream. |
static int |
readSwappedInt(java.io.InputStream in)
Reads one (signed) int from the stream. |
static short |
readSwappedShort(java.io.BufferedInputStream in)
Reads two bytes from the InputStream stored in a short-value. |
static short |
readSwappedShort(java.io.InputStream in)
Reads two bytes from the InputStream stored in a short-value. |
static int |
readSwappedUnsignedShort(java.io.BufferedInputStream in)
Reads two bytes from the InputStream, convertes them to a short and stores them to an int to preserve the sign. |
static int |
readSwappedUnsignedShort(java.io.InputStream in)
Reads two bytes from the InputStream, convertes them to a short and stores them to an int to preserve the sign. |
static short |
readUnsignedByte(java.io.BufferedInputStream in)
Reads one unsigned byte from the InputStream stored in a short-value to preserve the sign. |
static short |
readUnsignedByte(java.io.InputStream in)
Reads one unsigned byte from the InputStream stored in a short-value to preserve the sign. |
static int |
readUnsignedShort(java.io.BufferedInputStream in)
Reads two bytes from the InputStream, convertes them to a short and stores them to an int to preserve the sign. |
static int |
readUnsignedShort(java.io.InputStream in)
Reads two bytes from the InputStream, convertes them to a short and stores them to an int to preserve the sign. |
static void |
skipBytes(java.io.BufferedInputStream in,
long toSkip)
Skips and discards the given number of bytes from the given stream. |
static void |
skipBytes(java.io.InputStream in,
long toSkip)
Skips and discards the given number of bytes from the given stream. |
static long |
transferBytes(java.io.InputStream in,
byte[] buffer,
java.io.OutputStream out,
boolean closeIn,
boolean closeOut)
Reads all bytes from the provided InputStream and writes them to the provided OutputStream . |
static long |
transferBytes(java.io.InputStream in,
java.io.OutputStream out)
Reads all bytes from the provided InputStream and writes them to the provided OutputStream . |
static long |
transferBytes(java.io.InputStream in,
java.io.OutputStream out,
boolean closeIn,
boolean closeOut)
Reads all bytes from the provided InputStream and writes them to the provided OutputStream . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRANSFER_BUFFER_SIZE
Method Detail |
---|
public static final void skipBytes(java.io.InputStream in, long toSkip) throws java.io.IOException
in
- toSkip
-
java.io.IOException
public static final void skipBytes(java.io.BufferedInputStream in, long toSkip) throws java.io.IOException
in
- toSkip
-
java.io.IOException
public static final byte readByte(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final byte readByte(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readUnsignedByte(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readUnsignedByte(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readShort(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readShort(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readUnsignedShort(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readUnsignedShort(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readSwappedShort(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final short readSwappedShort(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readSwappedUnsignedShort(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readSwappedUnsignedShort(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readInt(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readInt(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readSwappedInt(java.io.InputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final int readSwappedInt(java.io.BufferedInputStream in) throws java.io.IOException
in
-
java.io.IOException
public static final void readBytes(java.io.InputStream in, int bytesToRead, byte[] buffer, int bufferOffset) throws java.io.IOException
in
- bytesToRead
- buffer
- bufferOffset
-
java.io.IOException
public static final void readBytes(java.io.BufferedInputStream in, int bytesToRead, byte[] buffer, int bufferOffset) throws java.io.IOException
in
- bytesToRead
- buffer
- bufferOffset
-
java.io.IOException
public static final java.lang.String readCString(java.io.InputStream in, int maxLength, boolean alwaysReadMaxLength) throws java.io.IOException
in
- maxLength
- alwaysReadMaxLength
-
java.io.IOException
public static final byte[] buildByteArray(java.io.InputStream in, int initialSize) throws java.io.IOException
initialSize
and is
enlarged on demand.
in
- the InputStream to get data frominitialSize
- the initial size of the output byte-array
java.io.IOException
public static final byte[] buildByteArray(java.io.InputStream in) throws java.io.IOException
buildByteArray(InputStream, int)
with an initialSize
of in.available().
in
- the InputStream to get data from
java.io.IOException
public static java.lang.Boolean closeStream(java.io.InputStream s)
null
ignoring theoretically irrelevant IOException.
s
- the stream to be closed. If null
, this is noop
null
, if the stream is null
, true
, if the closing was successful, false otherwise.public static java.lang.Boolean closeStream(java.io.OutputStream s)
null
ignoring theoretically irrelevant IOException.
Make sure, the stream is flushed before.
s
- the stream to be closed. If null
, this is noop
null
, if the stream is null
, true
, if the closing was successful, false otherwise.public static java.lang.Boolean flushStream(java.io.OutputStream s)
null
and ignores a rarely possible IOException
.
s
- the strema to flush
null
, if the stream is null
, true
, if the closing was successful, false otherwise.public static java.lang.Boolean closeReader(java.io.Reader r)
null
ignoring theoretically irrelevant IOException.
r
- the reader to be closed. If null
, this is noop
null
, if the reader is null
, true
, if the closing was successful, false otherwise.public static java.lang.Boolean closeWriter(java.io.Writer w)
null
ignoring theoretically irrelevant IOException.
Make sure, the stream is flushed before.
w
- the writer to be closed. If null
, this is noop
null
, if the writer is null
, true
, if the closing was successful, false otherwise.public static java.lang.Boolean flushWriter(java.io.Writer w)
null
and ignores a rarely possible IOException
.
w
- the writer to flush
null
, if the writer is null
, true
, if the closing was successful, false otherwise.public static long transferBytes(java.io.InputStream in, byte[] buffer, java.io.OutputStream out, boolean closeIn, boolean closeOut) throws java.io.IOException
InputStream
and writes them to the provided OutputStream
.
in
- buffer
- out
- closeIn
- if true
the provided InputStream
is closed after all.closeOut
- if true
the provided OutputStream
is closed after all.
java.io.IOException
public static long transferBytes(java.io.InputStream in, java.io.OutputStream out, boolean closeIn, boolean closeOut) throws java.io.IOException
InputStream
and writes them to the provided OutputStream
.
in
- out
- closeIn
- if true
the provided InputStream
is closed after all.closeOut
- if true
the provided OutputStream
is closed after all.
java.io.IOException
public static long transferBytes(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
and writes them to the provided OutputStream
.
The provided streams are closed after all.
in
- out
-
java.io.IOException
public static byte[] getBytesFromStream(java.io.InputStream in, boolean closeIn) throws java.io.IOException
InputStream
into a new byte array.
in
- closeIn
- if true
the provided InputStream
is closed after all.
InputStream
.
java.io.IOException
public static byte[] getBytesFromStream(java.io.InputStream in) throws java.io.IOException
InputStream
into a new byte array.
The provided stream is closed after all.
in
-
InputStream
.
java.io.IOException
public static java.lang.String getStringFromStream(java.io.InputStream in, boolean closeIn) throws java.io.IOException
InputStream
into a new String.
in
- closeIn
- if true
the provided InputStream
is closed after all.
InputStream
.
java.io.IOException
public static java.lang.String getStringFromStream(java.io.InputStream in) throws java.io.IOException
InputStream
into a new String.
The provided stream is closed after all.
in
-
InputStream
.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |