Class TeeInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
cloud.opencode.base.io.stream.TeeInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Tee Input Stream
分流输入流
Input stream that copies all data read to an output stream. Similar to the Unix 'tee' command.
将读取的所有数据复制到输出流的输入流。 类似于Unix的'tee'命令。
Features | 主要功能:
- Duplicate stream data - 复制流数据
- Optional close branch - 可选关闭分支
- Logging and debugging - 日志和调试
Usage Examples | 使用示例:
ByteArrayOutputStream copy = new ByteArrayOutputStream();
try (TeeInputStream tee = new TeeInputStream(input, copy)) {
process(tee); // Read from tee
}
byte[] data = copy.toByteArray(); // Get copy of data
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Field Summary
Fields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionTeeInputStream(InputStream in, OutputStream branch) Creates a tee input stream 创建分流输入流TeeInputStream(InputStream in, OutputStream branch, boolean closeBranch) Creates a tee input stream with close option 创建带关闭选项的分流输入流 -
Method Summary
Methods inherited from class FilterInputStream
available, mark, markSupported, read, reset, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
TeeInputStream
Creates a tee input stream 创建分流输入流- Parameters:
in- the underlying input stream | 底层输入流branch- the output stream to tee to | 分流到的输出流
-
TeeInputStream
Creates a tee input stream with close option 创建带关闭选项的分流输入流- Parameters:
in- the underlying input stream | 底层输入流branch- the output stream to tee to | 分流到的输出流closeBranch- whether to close branch on close | 关闭时是否关闭分支
-
-
Method Details
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
getBranch
Gets the branch output stream 获取分支输出流- Returns:
- branch output stream | 分支输出流
-
flushBranch
public void flushBranch()Flushes the branch output stream 刷新分支输出流
-