Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
默认缓存大小 8192
|
static int |
DEFAULT_LARGE_BUFFER_SIZE
默认大缓存大小 32768
|
static int |
DEFAULT_MIDDLE_BUFFER_SIZE
默认中等缓存大小 16384
|
static int |
EOF
数据流末尾
|
Constructor and Description |
---|
NioUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
close(AutoCloseable closeable)
关闭
关闭失败不会抛出异常 |
static long |
copy(FileChannel inChannel,
FileChannel outChannel)
拷贝文件Channel,使用NIO,拷贝后不会关闭channel
|
static long |
copy(ReadableByteChannel in,
WritableByteChannel out)
拷贝流,使用NIO,不会关闭channel
|
static long |
copy(ReadableByteChannel in,
WritableByteChannel out,
int bufferSize)
拷贝流,使用NIO,不会关闭channel
|
static long |
copy(ReadableByteChannel in,
WritableByteChannel out,
int bufferSize,
long count,
StreamProgress streamProgress)
拷贝流,使用NIO,不会关闭channel
|
static long |
copy(ReadableByteChannel in,
WritableByteChannel out,
int bufferSize,
StreamProgress streamProgress)
拷贝流,使用NIO,不会关闭channel
|
static long |
copyByNIO(InputStream in,
OutputStream out,
int bufferSize,
long count,
StreamProgress streamProgress)
拷贝流
本方法不会关闭流 |
static long |
copyByNIO(InputStream in,
OutputStream out,
int bufferSize,
StreamProgress streamProgress)
拷贝流 thanks to: https://github.com/venusdrogon/feilong-io/blob/master/src/main/java/com/feilong/io/IOWriteUtil.java
本方法不会关闭流 |
static String |
read(FileChannel fileChannel,
Charset charset)
从FileChannel中读取内容
|
static String |
read(FileChannel fileChannel,
String charsetName)
从FileChannel中读取内容,读取完毕后并不关闭Channel
|
static FastByteArrayOutputStream |
read(ReadableByteChannel channel)
从流中读取内容,读到输出流中
|
static String |
read(ReadableByteChannel channel,
Charset charset)
从流中读取内容,读取完毕后并不关闭流
|
static String |
readUtf8(FileChannel fileChannel)
从FileChannel中读取UTF-8编码内容
|
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_MIDDLE_BUFFER_SIZE
public static final int DEFAULT_LARGE_BUFFER_SIZE
public static final int EOF
public static long copyByNIO(InputStream in, OutputStream out, int bufferSize, StreamProgress streamProgress) throws IORuntimeException
in
- 输入流out
- 输出流bufferSize
- 缓存大小streamProgress
- 进度条IORuntimeException
- IO异常public static long copyByNIO(InputStream in, OutputStream out, int bufferSize, long count, StreamProgress streamProgress) throws IORuntimeException
in
- 输入流out
- 输出流bufferSize
- 缓存大小count
- 最大长度streamProgress
- 进度条IORuntimeException
- IO异常public static long copy(FileChannel inChannel, FileChannel outChannel) throws IORuntimeException
inChannel
- FileChannel
outChannel
- FileChannel
IORuntimeException
- IO异常public static long copy(ReadableByteChannel in, WritableByteChannel out) throws IORuntimeException
in
- ReadableByteChannel
out
- WritableByteChannel
IORuntimeException
- IO异常public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize) throws IORuntimeException
in
- ReadableByteChannel
out
- WritableByteChannel
bufferSize
- 缓冲大小,如果小于等于0,使用默认IORuntimeException
- IO异常public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, StreamProgress streamProgress) throws IORuntimeException
in
- ReadableByteChannel
out
- WritableByteChannel
bufferSize
- 缓冲大小,如果小于等于0,使用默认streamProgress
- StreamProgress
进度处理器IORuntimeException
- IO异常public static long copy(ReadableByteChannel in, WritableByteChannel out, int bufferSize, long count, StreamProgress streamProgress) throws IORuntimeException
in
- ReadableByteChannel
out
- WritableByteChannel
bufferSize
- 缓冲大小,如果小于等于0,使用默认count
- 读取总长度streamProgress
- StreamProgress
进度处理器IORuntimeException
- IO异常public static String read(ReadableByteChannel channel, Charset charset) throws IORuntimeException
channel
- 可读通道,读取完毕后并不关闭通道charset
- 字符集IORuntimeException
- IO异常public static FastByteArrayOutputStream read(ReadableByteChannel channel) throws IORuntimeException
channel
- 可读通道,读取完毕后并不关闭通道IORuntimeException
- IO异常public static String readUtf8(FileChannel fileChannel) throws IORuntimeException
fileChannel
- 文件管道IORuntimeException
- IO异常public static String read(FileChannel fileChannel, String charsetName) throws IORuntimeException
fileChannel
- 文件管道charsetName
- 字符集IORuntimeException
- IO异常public static String read(FileChannel fileChannel, Charset charset) throws IORuntimeException
fileChannel
- 文件管道charset
- 字符集IORuntimeException
- IO异常public static void close(AutoCloseable closeable)
closeable
- 被关闭的对象Copyright © 2024. All rights reserved.