public enum IOUtils extends Enum<IOUtils>
限定符和类型 | 方法和说明 |
---|---|
static void |
closeQuietly(Closeable is,
org.slf4j.Logger 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 void |
drainInputStream(InputStream in)
Read all remaining data in the stream.
|
static void |
release(Closeable is,
org.slf4j.Logger log)
Releases the given
Closeable especially if it was an instance of Releasable . |
static byte[] |
toByteArray(InputStream is)
Reads and returns the rest of the given input stream as a byte array.
|
static String |
toString(InputStream is)
Reads and returns the rest of the given input stream as a string.
|
static IOUtils |
valueOf(String name)
返回带有指定名称的该类型的枚举常量。
|
static IOUtils[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
public static IOUtils[] values()
for (IOUtils c : IOUtils.values()) System.out.println(c);
public static IOUtils valueOf(String name)
name
- 要返回的枚举常量的名称。IllegalArgumentException
- 如果该枚举类型没有带有指定名称的常量NullPointerException
- 如果参数为空值public static byte[] toByteArray(InputStream is) throws IOException
IOException
public static String toString(InputStream is) throws IOException
IOException
public static void closeQuietly(Closeable is, org.slf4j.Logger log)
is
- the given closeablelog
- logger used to log any failure should the close failpublic static void release(Closeable is, org.slf4j.Logger log)
Closeable
especially if it was an instance of Releasable
.
For example, the creation of a ResettableInputStream
would entail physically
opening a file. If the opened file is meant to be closed only (in a finally block) by the
very same code block that created it, then it is necessary that the release method must not
be called while the execution is made in other stack frames.
In such case, as other stack frames may inadvertently or indirectly call the close method of
the stream, the creator of the stream would need to explicitly disable the accidental closing
via ResettableInputStream#disableClose()
, so that the release method becomes the
only way to truly close the opened file.
public static long copy(InputStream in, OutputStream out) throws IOException
IOException
- if there is any IO exception during read or write.public static void drainInputStream(InputStream in)
in
- InputStream to read.Copyright © 2020. All rights reserved.