com.xiaoleilu.hutool
类 IoUtil

java.lang.Object
  继承者 com.xiaoleilu.hutool.IoUtil

public class IoUtil
extends Object

IO工具类

作者:
xiaoleilu

字段摘要
static int DEFAULT_BUFFER_SIZE
          默认缓存大小
 
构造方法摘要
IoUtil()
           
 
方法摘要
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 String getString(InputStream in, String charset)
          从流中读取内容
static ByteArrayInputStream toStream(String content, String charset)
          String 转为 流
static void write(OutputStream out, String charset, boolean isCloseOut, Object... contents)
          将多部分内容写到流中,自动转换为字符串
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
默认缓存大小

另请参见:
常量字段值
构造方法详细信息

IoUtil

public IoUtil()
方法详细信息

copy

public static int copy(Reader reader,
                       Writer writer)
                throws IOException
将Reader中的内容复制到Writer中 使用默认缓存大小

参数:
reader - Reader
writer - Writer
返回:
拷贝的字节数
抛出:
IOException

copy

public static int copy(Reader reader,
                       Writer writer,
                       int bufferSize)
                throws IOException
将Reader中的内容复制到Writer中

抛出:
IOException

copy

public static int copy(InputStream in,
                       OutputStream out)
                throws IOException
拷贝流,使用默认Buffer大小

参数:
in - 输入流
out - 输出流
抛出:
IOException

copy

public static int copy(InputStream in,
                       OutputStream out,
                       int bufferSize)
                throws IOException
拷贝流

参数:
in - 输入流
out - 输出流
bufferSize - 缓存大小
抛出:
IOException

copy

public static long copy(FileInputStream in,
                        FileOutputStream out)
                 throws IOException
拷贝文件流,使用NIO

参数:
in - 输入
out - 输出
返回:
拷贝的字节数
抛出:
IOException

getString

public static String getString(InputStream in,
                               String charset)
                        throws IOException
从流中读取内容

参数:
in - 输入流
charset - 字符集
返回:
内容
抛出:
IOException

toStream

public static ByteArrayInputStream toStream(String content,
                                            String charset)
String 转为 流

参数:
content - 内容
charset - 编码
返回:
字节流

write

public static void write(OutputStream out,
                         String charset,
                         boolean isCloseOut,
                         Object... contents)
                  throws IOException
将多部分内容写到流中,自动转换为字符串

参数:
out - 输出流
charset - 写出的内容的字符集
isCloseOut - 写入完毕是否关闭输出流
contents - 写入的内容,调用toString()方法,不包括不会自动换行
抛出:
IOException

echo

public static void echo(Object content,
                        Object... param)
打印内容,调用系统的System.out.println方法

参数:
content - 内容,会调用toString方法, 当内容中有 {} 表示变量占位符
param - 参数


Copyright © 2014. All rights reserved.