Class CountingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
cloud.opencode.base.io.stream.CountingInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
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:
-
Field Summary
Fields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class FilterInputStream
available, close, markSupported, readMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
CountingInputStream
Creates a counting input stream 创建计数输入流- Parameters:
in- the underlying input stream | 底层输入流
-
-
Method Details
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classFilterInputStream
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
getCount
public long getCount()Gets the number of bytes read 获取已读取字节数- Returns:
- byte count | 字节数
-
resetCount
public long resetCount()Resets the counter and returns the previous count 重置计数器并返回之前的计数- Returns:
- previous count | 之前的计数
-