public class IoTools extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
默认缓存大小
|
static int |
DEFAULT_LARGE_BUFFER_SIZE
默认缓存大小
|
static int |
EOF
数据流末尾
|
Constructor and Description |
---|
IoTools() |
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(Closeable... closeables)
关闭流
|
static void |
closeQuietly(Closeable closeable)
关闭数据流
|
static void |
closeQuietly(InputStream input)
关闭输入流
|
static void |
closeQuietly(OutputStream output)
关闭输出流
|
static void |
closeQuietly(Reader input)
关闭输入流
|
static void |
closeQuietly(Selector selector)
关闭选择器
|
static void |
closeQuietly(ServerSocket sock)
关闭serversocket端口
|
static void |
closeQuietly(Socket sock)
关闭socket端口
|
static void |
closeQuietly(Writer output)
关闭输出流
|
static long |
copy(InputStream input,
OutputStream output)
数据流复制
|
static long |
copy(InputStream input,
OutputStream output,
byte[] buffer)
数据流复制
|
static long |
copy(InputStream input,
OutputStream output,
byte[] buffer,
IStreamProgress streamProgress)
数据流复制
|
static long |
copy(InputStream input,
OutputStream output,
IStreamProgress streamProgress)
数据流复制
|
static long |
copyLarge(InputStream input,
OutputStream output)
支持复制容量超过2GB的数据流
|
static long |
copyLarge(InputStream input,
OutputStream output,
byte[] buffer)
支持复制容量超过2GB的数据流
|
static long |
copyLarge(InputStream input,
OutputStream output,
byte[] buffer,
IStreamProgress streamProgress)
支持复制容量超过2GB的数据流
|
static long |
copyLarge(InputStream input,
OutputStream output,
IStreamProgress streamProgress)
支持复制容量超过2GB的数据流
|
static long |
copyLarge(InputStream input,
OutputStream output,
long inputOffset,
IStreamProgress streamProgress)
从指定位置复制数据流,使用缺省的缓存大小
|
static long |
copyLarge(InputStream input,
OutputStream output,
long inputOffset,
long length,
byte[] buffer,
IStreamProgress streamProgress)
从指定位置复制指定长度的数据流
|
static long |
copyLarge(InputStream input,
OutputStream output,
long inputOffset,
long length,
IStreamProgress streamProgress)
从指定位置复制指定长度的数据流,使用缺省的缓存大小
|
static List<String> |
readLineToStringList(InputStream inputStream,
Charset charset)
读取数据流到字符串集合(按行分隔),并制定字符编码。
缺省使用当前操作系统缺省字符编码(windows 时 GBK,UNIX 是 utf-8) |
static List<String> |
readLineToStringListUTF8(InputStream inputStream)
读取数据流到字符串集合(按行分隔),UTF-8字符编码
|
static byte[] |
readToByte(InputStream input,
int offset,
int length,
IStreamProgress streamProgress)
读取数据流
|
static char[] |
readToCharsHex(InputStream inputStream,
int length,
boolean isLowerCase)
读取数据流,并以16进制表示
|
static String |
readToHex56Upper(InputStream inputStream)
读取数据流的前56字节,并以16进制表示(英文字母大写)
|
static String |
readToString(InputStream input,
Charset charset)
读取数据流到字符串,并制定字符编码。
缺省使用当前操作系统缺省字符编码(windows 时 GBK,UNIX 是 utf-8) |
static String |
readToStringHex(InputStream inputStream,
int length,
boolean isLowerCase)
读取数据流,并以16进制表示
|
static String |
readToStringUTF8(InputStream input)
读取数据流到字符串,以utf-8字符编码
|
static String |
readToStringUTF8(InputStream input,
int offset,
int length,
IStreamProgress streamProgress)
读取数据流到字符串,以utf-8字符编码
|
static long |
skip(InputStream input,
long toSkip)
跳过(忽略)输入流的指定长度
|
static void |
skipFully(InputStream input,
long toSkip)
跳过(忽略)输入流的指定长度
|
static InputStream |
toInputStream(String input,
Charset encoding)
将字符串转化为输入流
|
static InputStream |
toInputStream(String input,
String encoding)
将字符串转化为输入流
|
static void |
write(byte[] data,
OutputStream output)
将byte数组写入到输出流
|
static void |
write(byte[] data,
Writer output,
Charset encoding)
将byte数组按照指定字符编码写入输出流
|
static void |
write(String data,
OutputStream output,
Charset encoding)
将字符串按照指定字符编码写入输出流
|
static void |
writeChunked(byte[] data,
OutputStream output)
带有缓冲区的将byte数组写入到输出流
|
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_LARGE_BUFFER_SIZE
public static final int EOF
public static long copy(InputStream input, OutputStream output) throws IOException
input
- output
- IOException
public static long copy(InputStream input, OutputStream output, byte[] buffer) throws IOException
input
- output
- buffer
- IOException
public static long copy(InputStream input, OutputStream output, IStreamProgress streamProgress) throws IOException
input
- output
- streamProgress
- IOException
public static long copy(InputStream input, OutputStream output, byte[] buffer, IStreamProgress streamProgress) throws IOException
input
- output
- buffer
- streamProgress
- IOException
public static long copyLarge(InputStream input, OutputStream output) throws IOException
input
- output
- IOException
public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException
input
- output
- buffer
- IOException
public static long copyLarge(InputStream input, OutputStream output, IStreamProgress streamProgress) throws IOException
input
- output
- streamProgress
- IOException
public static long copyLarge(InputStream input, OutputStream output, byte[] buffer, IStreamProgress streamProgress) throws IOException
input
- output
- buffer
- 缓存streamProgress
- 数据读取进度条IOException
public static long copyLarge(InputStream input, OutputStream output, long inputOffset, IStreamProgress streamProgress) throws IOException
input
- output
- inputOffset
- streamProgress
- IOException
public static long copyLarge(InputStream input, OutputStream output, long inputOffset, long length, IStreamProgress streamProgress) throws IOException
input
- output
- inputOffset
- length
- streamProgress
- IOException
public static long copyLarge(InputStream input, OutputStream output, long inputOffset, long length, byte[] buffer, IStreamProgress streamProgress) throws IOException
input
- 输入流output
- 输出流inputOffset
- 输入流欲读取的指定位置(起始点)length
- 欲读取流的长度buffer
- 缓存streamProgress
- 读取进度IOException
public static byte[] readToByte(InputStream input, int offset, int length, IStreamProgress streamProgress) throws IOException
input
- offset
- length
- streamProgress
- IOException
public static String readToStringUTF8(InputStream input, int offset, int length, IStreamProgress streamProgress) throws IOException
input
- offset
- length
- streamProgress
- IOException
public static String readToStringUTF8(InputStream input) throws IOException
input
- IOException
public static List<String> readLineToStringListUTF8(InputStream inputStream) throws IOException
inputStream
- IOException
public static List<String> readLineToStringList(InputStream inputStream, Charset charset) throws IOException
inputStream
- charset
- IOException
public static String readToString(InputStream input, Charset charset) throws IOException
input
- charset
- IOException
public static String readToStringHex(InputStream inputStream, int length, boolean isLowerCase) throws IOException
inputStream
- length
- 读取的长度isLowerCase
- 是否英文小写字母IOException
public static char[] readToCharsHex(InputStream inputStream, int length, boolean isLowerCase) throws IOException
inputStream
- length
- isLowerCase
- IOException
public static String readToHex56Upper(InputStream inputStream) throws IOException
inputStream
- IOException
public static void write(byte[] data, OutputStream output) throws IOException
data
- output
- IOException
public static void write(byte[] data, Writer output, Charset encoding) throws IOException
data
- output
- encoding
- IOException
public static void write(String data, OutputStream output, Charset encoding) throws IOException
data
- output
- encoding
- IOException
public static void writeChunked(byte[] data, OutputStream output) throws IOException
data
- output
- IOException
public static void closeQuietly(Reader input)
input
- public static void closeQuietly(Writer output)
output
- public static void closeQuietly(InputStream input)
input
- public static void closeQuietly(OutputStream output)
output
- public static void closeQuietly(Closeable... closeables)
closeables
- public static void closeQuietly(Socket sock)
sock
- public static void closeQuietly(Closeable closeable)
closeable
- public static void closeQuietly(Selector selector)
selector
- public static void closeQuietly(ServerSocket sock)
sock
- public static InputStream toInputStream(String input, Charset encoding)
input
- encoding
- public static InputStream toInputStream(String input, String encoding) throws IOException
input
- encoding
- IOException
public static long skip(InputStream input, long toSkip) throws IOException
input
- toSkip
- IOException
public static void skipFully(InputStream input, long toSkip) throws IOException
input
- toSkip
- IOException
Copyright © 2018. All rights reserved.