public class IoUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger |
Constructor and Description |
---|
IoUtils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
from(java.io.InputStream in)
Read from
in and return all bytes. |
static java.lang.String |
from(java.io.Reader reader)
Read from
reader and return string. |
static byte[] |
getChecksum(java.io.InputStream in)
Calculate checksum.
|
static java.lang.String |
getChecksumAsString(java.io.InputStream in)
Calculate checksum as string.
|
static int |
redirect(java.io.InputStream from,
java.io.OutputStream to)
Redirect
from to to . |
static int |
redirect(java.io.Reader from,
java.io.Writer to)
Redirect
from to to . |
static int |
stream(java.io.InputStream in,
StreamConsumer consumer)
Process streaming.
|
static void |
tryFlush(java.lang.Object... flushable)
Call #flush if possible.
|
public static void tryFlush(java.lang.Object... flushable)
Call #flush if the element of flushables
is next:
Flushable
flushable
- object instances to flushpublic static int stream(java.io.InputStream in, StreamConsumer consumer) throws java.lang.Exception
in
- InputStream
consumer
- instance to use streamingjava.io.IOException
- If fail to read or processjava.lang.Exception
public static int redirect(java.io.InputStream from, java.io.OutputStream to) throws java.io.IOException
from
to to
.from
- InputStream
to readto
- OutputStream
to writejava.io.IOException
- Fail to read or writepublic static int redirect(java.io.Reader from, java.io.Writer to) throws java.io.IOException
from
to to
.from
- Reader
to readto
- Writer
to writejava.io.IOException
- Fail to read or writepublic static byte[] from(java.io.InputStream in) throws java.io.IOException
in
and return all bytes.in
- InputStream
to readjava.io.IOException
- Fail to readpublic static java.lang.String from(java.io.Reader reader) throws java.io.IOException
reader
and return string.reader
- Reader
to readjava.io.IOException
- Fail to readpublic static byte[] getChecksum(java.io.InputStream in) throws java.io.IOException, java.security.NoSuchAlgorithmException
in
- InputStream
containing contentjava.io.IOException
- Fail to read contentjava.security.NoSuchAlgorithmException
- No MD5 algorithmpublic static java.lang.String getChecksumAsString(java.io.InputStream in) throws java.io.IOException, java.security.NoSuchAlgorithmException
in
- InputStream
containing contentjava.io.IOException
- Fail to read contentjava.security.NoSuchAlgorithmException
- No MD5 algorithm