Class TeeInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
cloud.opencode.base.io.stream.TeeInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class TeeInputStream extends FilterInputStream
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:
  • Constructor Details

    • TeeInputStream

      public TeeInputStream(InputStream in, OutputStream branch)
      Creates a tee input stream 创建分流输入流
      Parameters:
      in - the underlying input stream | 底层输入流
      branch - the output stream to tee to | 分流到的输出流
    • TeeInputStream

      public TeeInputStream(InputStream in, OutputStream branch, boolean closeBranch)
      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