public class StreamCopier extends IoCopier<InputStream,OutputStream>
InputStream 向 OutputStream 拷贝bufferSize, count, flushEveryBuffer| 构造器和说明 |
|---|
StreamCopier()
构造
|
StreamCopier(int bufferSize)
构造
|
StreamCopier(int bufferSize,
long count)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
long |
copy(InputStream source,
OutputStream target)
执行拷贝
|
private long |
doCopy(InputStream source,
OutputStream target,
byte[] buffer)
执行拷贝,如果限制最大长度,则按照最大长度读取,否则一直读取直到遇到-1
|
bufferSize, setFlushEveryBufferpublic StreamCopier()
public StreamCopier(int bufferSize)
bufferSize - 缓存大小public StreamCopier(int bufferSize,
long count)
bufferSize - 缓存大小count - 拷贝总数public long copy(InputStream source, OutputStream target)
IoCopiercopy 在类中 IoCopier<InputStream,OutputStream>source - 拷贝源,如InputStream、Reader等target - 拷贝目标,如OutputStream、Writer等private long doCopy(InputStream source, OutputStream target, byte[] buffer) throws IOException
source - InputStreamtarget - OutputStreambuffer - 缓存IOException - IO异常Copyright © 2024. All rights reserved.