public final class StreamUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EOF_EXCEPTION_MESSAGE_BYTES
Message used in thrown exception when a stream end is encountered prematurely.
|
static java.lang.String |
EOF_EXCEPTION_MESSAGE_CHARACTERS
Message used in thrown exception when a stream end is encountered prematurely.
|
Modifier and Type | Method and Description |
---|---|
static void |
copy(java.io.InputStream from,
java.io.OutputStream to,
long length)
Copies data from one stream to another.
|
static char |
peekCharacter(java.io.Reader textStream)
Peeks the next stream character, if any.
|
static java.lang.String |
readAllCharacters(java.io.InputStream stream)
Blocks until all bytes are read from the stream, returns the decoded data using the UTF8 encoding.
|
static java.lang.String |
readAllCharacters(java.io.InputStream stream,
java.nio.charset.Charset streamEncoding)
Blocks until all bytes are read from the stream, returns the decoded data using the specified encoding.
|
static java.lang.String |
readAllCharacters(java.io.Reader textStream)
Reads all characters from a stream, returning a string.
|
static char |
readCharacter(java.io.InputStream stream)
Reads the next character, if any, from a UTF8-encoded byte-stream,decoding bytes UTF8 format.
|
static char |
readCharacter(java.io.InputStream stream,
java.nio.charset.Charset streamEncoding)
Reads the next character from a byte-stream, if any, decoding bytes into the specified encoding's decoder e.g.
|
static char |
readCharacter(java.io.Reader textStream)
Reads the next stream character, if any.
|
static char[] |
readCharacters(java.io.InputStream stream,
java.nio.charset.Charset streamEncoding,
int count)
Reads the next characters, if any, from a , decoding bytes using the specified decoder.
|
static char[] |
readCharacters(java.io.InputStream stream,
int count)
Reads the next characters, if any, from a ,decoding bytes using the UTF8 decoder.
|
static char[] |
readCharacters(java.io.Reader textStream,
int count)
Reads the next stream characters, if any.
|
static void |
readFully(java.io.InputStream stream,
byte[] buffer,
long length)
Blocks until a specified amount of bytes is read from a stream.
|
static void |
readFully(java.io.InputStream stream,
byte[] buffer,
long length,
int maxChunkSize)
Blocks until a specified amount of bytes is read from a stream.
|
static byte[] |
readFully(java.io.InputStream stream,
long length)
Blocks until a specified amount of bytes is read from a stream.
|
static byte[] |
readFully(java.io.InputStream stream,
long length,
int maxChunkSize)
Blocks until a specified amount of bytes is read from a stream.
|
static java.lang.String |
readFully(java.io.Reader textStream,
int count)
Reads a specified number of characters from the stream.
|
static byte[] |
readUntil(java.io.InputStream stream,
byte terminator)
Reads data from the stream until a terminator byte is found.
|
static byte[] |
readUntil(java.io.InputStream stream,
byte[] terminator)
Reads data from the byte-stream until a terminator string is found.
|
static java.lang.String |
readUntil(java.io.InputStream stream,
byte[] terminator,
java.nio.charset.Charset streamEncoding)
Reads a string from the byte-stream with the specified encoding until a terminator string is found.
|
static java.lang.String |
readUntil(java.io.InputStream stream,
char terminator)
Reads a string from the UTF8-encoded byte-stream until a terminator character is found.
|
static java.lang.String |
readUntil(java.io.InputStream stream,
char terminator,
java.nio.charset.Charset streamEncoding)
Reads a string from the stream until a terminator character is found.
|
static java.lang.String |
readUntil(java.io.InputStream stream,
java.lang.String terminator)
Reads a string from the UTF8-encoded byte-stream until a terminator string is found.
|
static java.lang.String |
readUntil(java.io.InputStream stream,
java.lang.String terminator,
java.nio.charset.Charset streamEncoding)
Reads a string from the byte-stream with the specified encoding until a terminator string is found.
|
static java.lang.String |
readUntil(java.io.Reader textStream,
char terminator)
Reads a string from the stream until a terminator character is found.
|
static java.lang.String |
readUntil(java.io.Reader textStream,
java.lang.String terminator)
Reads a string from the stream until a terminator string is found.
|
static java.lang.String |
readUntilPeeking(java.io.Reader textStream,
char terminator)
Reads a string from the stream until a terminator character is found.
|
static void |
skipBytes(java.io.InputStream stream,
int length)
Blocks until a specified amount of bytes is read from a stream.
|
static void |
skipCharacters(java.io.InputStream stream,
int count)
Skips a specified number of characters from byte-stream, using UTF8 to convert bytes into characters.
|
static void |
skipCharacters(java.io.InputStream stream,
int count,
java.nio.charset.Charset streamEncoding)
Skips a specified number of characters from the byte-stream, using the specified encoding to convert bytes into characters.
|
static void |
skipCharacters(java.io.Reader textStream,
int count)
Skips a specified number of characters from the stream
|
static void |
skipUntil(java.io.InputStream stream,
byte terminator)
Blocks until the specified byte is encountered and all bytes read until then are skipped.
|
static void |
skipUntil(java.io.InputStream stream,
byte[] terminator)
Blocks until the specified byte sequence is encountered and all bytes read until then are skipped.
|
static void |
skipUntil(java.io.InputStream stream,
char terminator)
Blocks until the specified character is encountered and all characters read until then from the UTF8-encoded byte-stream are skipped.
|
static void |
skipUntil(java.io.InputStream stream,
char terminator,
java.nio.charset.Charset streamEncoding)
Blocks until the specified character is encountered and all characters read until then from the byte-stream are skipped.
|
static void |
skipUntil(java.io.InputStream stream,
java.lang.String terminator)
Blocks until the specified string of characters is encountered and all characters read until then from the byte-stream are skipped.
|
static void |
skipUntil(java.io.InputStream stream,
java.lang.String terminator,
java.nio.charset.Charset streamEncoding)
Blocks until the specified string of characters is encountered and all characters read until then from the UTF8-encoded byte-stream are
skipped.
|
static void |
skipUntil(java.io.Reader textStream,
char terminator)
Skips characters in the stream until the specified character is read
|
static void |
skipUntil(java.io.Reader textStream,
java.lang.String terminator)
Skips characters in the stream until the specified string is read
|
static void |
writeFully(java.io.OutputStream stream,
byte[] data)
Blocks until all data is written to the given stream.
|
static void |
writeFully(java.io.OutputStream stream,
byte[] data,
int maxChunkSize)
Blocks until all data is written to the given stream.
|
public static final java.lang.String EOF_EXCEPTION_MESSAGE_BYTES
public static final java.lang.String EOF_EXCEPTION_MESSAGE_CHARACTERS
public static void copy(java.io.InputStream from, java.io.OutputStream to, long length) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void writeFully(java.io.OutputStream stream, byte[] data) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void writeFully(java.io.OutputStream stream, byte[] data, int maxChunkSize) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static java.lang.String readAllCharacters(java.io.InputStream stream) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readAllCharacters(java.io.InputStream stream, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void readFully(java.io.InputStream stream, byte[] buffer, long length) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static byte[] readFully(java.io.InputStream stream, long length) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void readFully(java.io.InputStream stream, byte[] buffer, long length, int maxChunkSize) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static byte[] readFully(java.io.InputStream stream, long length, int maxChunkSize) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, char terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, char terminator, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, java.lang.String terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, java.lang.String terminator, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, byte terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.InputStream stream, byte[] terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipBytes(java.io.InputStream stream, int length) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void skipCharacters(java.io.InputStream stream, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void skipCharacters(java.io.InputStream stream, int count, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.InputStream stream, char terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.InputStream stream, char terminator, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.InputStream stream, java.lang.String terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.InputStream stream, java.lang.String terminator, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static byte[] readUntil(java.io.InputStream stream, byte terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static byte[] readUntil(java.io.InputStream stream, byte[] terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.InputStream stream, byte[] terminator, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static char[] readCharacters(java.io.InputStream stream, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static char[] readCharacters(java.io.InputStream stream, java.nio.charset.Charset streamEncoding, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static char readCharacter(java.io.InputStream stream) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static char readCharacter(java.io.InputStream stream, java.nio.charset.Charset streamEncoding) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readAllCharacters(java.io.Reader textStream) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.Reader textStream, char terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static void skipUntil(java.io.Reader textStream, java.lang.String terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readFully(java.io.Reader textStream, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static void skipCharacters(java.io.Reader textStream, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.Reader textStream, char terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntil(java.io.Reader textStream, java.lang.String terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static java.lang.String readUntilPeeking(java.io.Reader textStream, char terminator) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- A stream was passed that does not support peeking (mark/reset)java.io.IOException
- An I/O exception occurred.public static char readCharacter(java.io.Reader textStream) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.io.IOException
- An I/O exception occurred.public static char[] readCharacters(java.io.Reader textStream, int count) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- An argument is out of range.java.io.IOException
- An I/O exception occurred.public static char peekCharacter(java.io.Reader textStream) throws java.io.IOException
java.lang.NullPointerException
- An argument is null.java.lang.IllegalArgumentException
- A stream was passed that does not support peeking (mark/reset)java.io.IOException
- An I/O exception occurred.