Class CountingInputStream

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

public class CountingInputStream extends FilterInputStream
Counting Input Stream 计数输入流

Input stream wrapper that counts the number of bytes read. Useful for progress tracking and statistics.

统计读取字节数的输入流包装器。 用于进度追踪和统计。

Features | 主要功能:

  • Count bytes read - 统计读取字节数
  • Reset counter - 重置计数器
  • Progress tracking - 进度追踪

Usage Examples | 使用示例:

try (CountingInputStream counting = new CountingInputStream(input)) {
    byte[] data = counting.readAllBytes();
    System.out.println("Read " + counting.getCount() + " bytes");
}

Security | 安全性:

  • Thread-safe: No - 线程安全: 否
Since:
JDK 25, opencode-base-io V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CountingInputStream

      public CountingInputStream(InputStream in)
      Creates a counting input stream 创建计数输入流
      Parameters:
      in - the underlying input stream | 底层输入流
  • Method Details