public final class StreamUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CHUNK_SIZE
Buffer size of chunked operations, e.g.
|
| Modifier | Constructor and Description |
|---|---|
private |
StreamUtil()
Private method of utility class.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
closeReader(java.io.Reader reader)
Closes the given reader and swallows exceptions that may arise during the process.
|
static void |
closeStream(java.io.InputStream in)
Closes the given stream and swallows exceptions that may arise during the process.
|
static void |
closeStream(java.io.OutputStream out)
Closes the given stream and swallows exceptions that may arise during the process.
|
static void |
closeWriter(java.io.Writer writer)
Closes the given writer and swallows exceptions that may arise during the process.
|
static java.io.Reader |
makeReader(java.io.File file)
Creates a reader around the given file that presumably contains character data.
|
static java.io.InputStream |
makeStream(java.io.File file)
Creates an input stream around the given file.
|
static void |
pipeAll(java.io.InputStream in,
java.io.OutputStream out,
ChunkHandler handler)
Pipes an input stream into an output stream with chuncked processing.
|
static byte[] |
readAll(java.io.File file)
Reads all the data from the given file.
|
static byte[] |
readAll(java.io.InputStream input)
Reads all the data from the given input stream.
|
static byte[] |
readAll(java.io.InputStream input,
int sizeHint)
Reads all the data from the given input stream.
|
static java.lang.String |
readAll(java.io.Reader reader)
Reads all data from the given reader.
|
static java.lang.String |
readAll(java.io.Reader reader,
int sizeHint)
Reads all data from the given reader.
|
static byte[] |
readAll(java.lang.String path)
Reads all the data from the file at the given path.
|
public static final int CHUNK_SIZE
pipeAll(java.io.InputStream, java.io.OutputStream,
org.cryptacular.io.ChunkHandler).public static byte[] readAll(java.lang.String path)
throws StreamException
path - Path to file.StreamException - on stream IO errors.public static byte[] readAll(java.io.File file)
throws StreamException
file - File to read.StreamException - on stream IO errors.public static byte[] readAll(java.io.InputStream input)
throws StreamException
input - Input stream to read.StreamException - on stream IO errors.public static byte[] readAll(java.io.InputStream input,
int sizeHint)
throws StreamException
input - Input stream to read.sizeHint - Estimate of amount of data to be read in bytes.StreamException - on stream IO errors.public static java.lang.String readAll(java.io.Reader reader)
throws StreamException
reader - Reader over character data.StreamException - on stream IO errors.public static java.lang.String readAll(java.io.Reader reader,
int sizeHint)
throws StreamException
reader - Reader over character data.sizeHint - Estimate of amount of data to be read in number of characters.StreamException - on stream IO errors.public static void pipeAll(java.io.InputStream in,
java.io.OutputStream out,
ChunkHandler handler)
throws StreamException
in - Input stream providing data to process.out - Output stream holding processed data.handler - Arbitrary handler for processing input stream.StreamException - on stream IO errors.public static java.io.InputStream makeStream(java.io.File file)
throws StreamException
file - Input stream source.StreamException - on stream IO errors.public static java.io.Reader makeReader(java.io.File file)
throws StreamException
file - Reader source.StreamException - on stream IO errors.public static void closeStream(java.io.InputStream in)
in - Input stream to close.public static void closeStream(java.io.OutputStream out)
out - Output stream to close.public static void closeReader(java.io.Reader reader)
reader - Reader to close.public static void closeWriter(java.io.Writer writer)
writer - Writer to close.