public class IoUtil
extends org.springframework.util.StreamUtils
| Constructor and Description |
|---|
IoUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(Closeable closeable)
closeQuietly
|
static byte[] |
readToByteArray(InputStream input) |
static String |
readToString(InputStream input)
InputStream to String utf-8
|
static String |
readToString(InputStream input,
Charset charset)
InputStream to String
|
static void |
write(String data,
OutputStream output,
Charset encoding)
Writes chars from a
String to bytes on an
OutputStream using the specified character encoding. |
public static void closeQuietly(@Nullable
Closeable closeable)
closeable - 自动关闭public static String readToString(InputStream input)
input - the InputStream to read frompublic static String readToString(@Nullable InputStream input, Charset charset)
input - the InputStream to read fromcharset - the Charsetpublic static byte[] readToByteArray(@Nullable
InputStream input)
public static void write(@Nullable
String data,
OutputStream output,
Charset encoding)
throws IOException
String to bytes on an
OutputStream using the specified character encoding.
This method uses String.getBytes(String).
data - the String to write, null ignoredoutput - the OutputStream to write toencoding - the encoding to use, null means platform defaultNullPointerException - if output is nullIOException - if an I/O error occursCopyright © 2024. All rights reserved.