Package tech.mgl.core.utils
Class MGL_StreamUtils
java.lang.Object
tech.mgl.core.utils.MGL_StreamUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intbufferSize(long count) 缓存大小,取默认缓存和目标长度最小值static void关闭
关闭失败不会抛出异常static longcopy(FileInputStream in, FileOutputStream out) 拷贝文件流,使用NIOstatic longcopy(InputStream in, OutputStream out) 拷贝流,使用默认Buffer大小,拷贝后不关闭流static longcopy(InputStream in, OutputStream out, int bufferSize, long count, MGLStreamProgress streamProgress) static longcopy(FileChannel inChannel, FileChannel outChannel) 拷贝文件Channel,使用NIO,拷贝后不会关闭channellongcopy(ReadableByteChannel source, WritableByteChannel target, long count) static FastByteArrayOutputStreamread(InputStream in, boolean isClose) static byte[]readBytes(InputStream in, boolean isClose)
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE默认缓存大小 8192- See Also:
-
-
Constructor Details
-
MGL_StreamUtils
public MGL_StreamUtils()
-
-
Method Details
-
copy
拷贝文件Channel,使用NIO,拷贝后不会关闭channel- Parameters:
inChannel-FileChanneloutChannel-FileChannel- Returns:
- 拷贝的字节数
- Throws:
RuntimeException- IO异常- Since:
- 5.5.3
-
readBytes
public static byte[] readBytes(InputStream in, boolean isClose) throws RuntimeException, IOException - Throws:
RuntimeExceptionIOException
-
copy
拷贝流,使用默认Buffer大小,拷贝后不关闭流- Parameters:
in- 输入流out- 输出流- Returns:
- 传输的byte数
- Throws:
RuntimeException- IO异常
-
copy
public static long copy(InputStream in, OutputStream out, int bufferSize, long count, MGLStreamProgress streamProgress) throws RuntimeException - Throws:
RuntimeException
-
read
- Throws:
IOException
-
copy
拷贝文件流,使用NIO- Parameters:
in- 输入out- 输出- Returns:
- 拷贝的字节数
- Throws:
RuntimeException- IO异常
-
close
关闭
关闭失败不会抛出异常- Parameters:
closeable- 被关闭的对象
-
bufferSize
protected int bufferSize(long count) 缓存大小,取默认缓存和目标长度最小值- Parameters:
count- 目标长度- Returns:
- 缓存大小
-
copy
-