public class IOUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
closeIfCloseable(Object maybeCloseable,
ClientLogger log)
Closes the given Closeable quietly.
|
static void |
closeQuietly(AutoCloseable is,
ClientLogger log)
Closes the given Closeable quietly.
|
static long |
copy(InputStream in,
OutputStream out)
Copies all bytes from the given input stream to the given output stream.
|
static long |
copy(InputStream in,
OutputStream out,
long readLimit)
Copies all bytes from the given input stream to the given output stream.
|
static void |
drainInputStream(InputStream in)
Read all remaining data in the stream.
|
static void |
markStreamWithMaxReadLimit(InputStream s)
If the stream supports marking, marks the stream at the current position with a
readLimit value of
128 KiB. |
static byte[] |
toByteArray(InputStream is)
Reads and returns the rest of the given input stream as a byte array.
|
static String |
toUtf8String(InputStream is)
Reads and returns the rest of the given input stream as a string.
|
public static byte[] toByteArray(InputStream is) throws IOException
IOExceptionpublic static String toUtf8String(InputStream is) throws IOException
IOExceptionpublic static void closeQuietly(AutoCloseable is, ClientLogger log)
is - the given closeablelog - logger used to log any failure should the close failpublic static void closeIfCloseable(Object maybeCloseable, ClientLogger log)
maybeCloseable - the given closeablelog - logger used to log any failure should the close failpublic static long copy(InputStream in, OutputStream out) throws IOException
IOException - if there is any IO exception during read or write.public static long copy(InputStream in, OutputStream out, long readLimit) throws IOException
IOException - if there is any IO exception during read or write or the read limit is exceeded.public static void drainInputStream(InputStream in)
in - InputStream to read.public static void markStreamWithMaxReadLimit(InputStream s)
readLimit value of
128 KiB.s - The stream.Copyright © 2024. All rights reserved.