public class IoUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
默认缓存大小
|
| 构造器和说明 |
|---|
IoUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
close(AutoCloseable closeable)
关闭
|
static void |
close(Closeable closeable)
关闭
|
static long |
copy(FileInputStream in,
FileOutputStream out)
拷贝文件流,使用NIO
|
static int |
copy(InputStream in,
OutputStream out)
拷贝流,使用默认Buffer大小
|
static int |
copy(InputStream in,
OutputStream out,
int bufferSize)
拷贝流
|
static int |
copy(Reader reader,
Writer writer)
将Reader中的内容复制到Writer中
使用默认缓存大小
|
static int |
copy(Reader reader,
Writer writer,
int bufferSize)
将Reader中的内容复制到Writer中
|
static void |
echo(Object content,
Object... param)
打印内容,调用系统的System.out.println方法
|
static BufferedReader |
getReader(InputStream in,
Charset charset)
获得一个文件读取器
|
static BufferedReader |
getReader(InputStream in,
String charsetName)
获得一个文件读取器
|
static String |
read(FileChannel fileChannel,
String charset)
从FileChannel中读取内容
|
static String |
read(InputStream in,
String charset)
从流中读取内容
|
static String |
read(Reader reader)
从Reader中读取String
|
static byte[] |
readBytes(InputStream in)
从流中读取bytes
|
static <T extends Collection<String>> |
readLines(InputStream in,
String charset,
T collection)
从流中读取内容
|
static ByteArrayInputStream |
toStream(String content,
String charset)
String 转为 流
|
static void |
write(OutputStream out,
String charset,
boolean isCloseOut,
Object... contents)
将多部分内容写到流中,自动转换为字符串
|
public static final int DEFAULT_BUFFER_SIZE
public static int copy(Reader reader, Writer writer) throws IOException
reader - Readerwriter - WriterIOExceptionpublic static int copy(Reader reader, Writer writer, int bufferSize) throws IOException
reader - Readerwriter - WriterbufferSize - 缓存大小IOExceptionpublic static int copy(InputStream in, OutputStream out) throws IOException
in - 输入流out - 输出流IOExceptionpublic static int copy(InputStream in, OutputStream out, int bufferSize) throws IOException
in - 输入流out - 输出流bufferSize - 缓存大小IOExceptionpublic static long copy(FileInputStream in, FileOutputStream out) throws IOException
in - 输入out - 输出IOExceptionpublic static BufferedReader getReader(InputStream in, String charsetName) throws IOException
in - 输入流charsetName - 字符集名称IOExceptionpublic static BufferedReader getReader(InputStream in, Charset charset) throws IOException
in - 输入流charset - 字符集IOExceptionpublic static byte[] readBytes(InputStream in) throws IOException
in - 输入流IOExceptionpublic static String read(InputStream in, String charset) throws IOException
in - 输入流charset - 字符集IOExceptionpublic static String read(Reader reader) throws IOException
reader - ReaderIOExceptionpublic static String read(FileChannel fileChannel, String charset) throws IOException
fileChannel - 文件管道charset - 字符集IOExceptionpublic static <T extends Collection<String>> T readLines(InputStream in, String charset, T collection) throws IOException
in - 输入流charset - 字符集collection - 返回集合IOExceptionpublic static ByteArrayInputStream toStream(String content, String charset)
content - 内容charset - 编码public static void write(OutputStream out, String charset, boolean isCloseOut, Object... contents) throws IOException
out - 输出流charset - 写出的内容的字符集isCloseOut - 写入完毕是否关闭输出流contents - 写入的内容,调用toString()方法,不包括不会自动换行IOExceptionpublic static void echo(Object content, Object... param)
content - 内容,会调用toString方法, 当内容中有 {} 表示变量占位符param - 参数public static void close(Closeable closeable)
closeable - 被关闭的对象public static void close(AutoCloseable closeable)
closeable - 被关闭的对象Copyright © 2016. All rights reserved.