- All Superinterfaces:
AutoCloseable,Closeable,Flushable
- All Known Subinterfaces:
BufferSink
- All Known Implementing Classes:
AssignSink,Buffer,DeflaterSink,FaultHideSink,GzipSink,RealSink
字节流接收器接口,用于将数据写入目标(如网络、存储或内存缓冲区)。 支持分层处理以转换数据(如压缩、加密、节流或协议框架)。 通过
BufferSink.outputStream() 可适配为
OutputStream。- Since:
- Java 17+
- Author:
- Kimi Liu
-
Method Summary
-
Method Details
-
write
从源读取指定字节数并写入当前接收器。- Parameters:
source- 数据源缓冲区byteCount- 要读取的字节数- Throws:
IOException- 如果读取或写入失败
-
flush
将缓冲区中的所有数据推送到最终目标。- Specified by:
flushin interfaceFlushable- Throws:
IOException- 如果刷新失败
-
timeout
Timeout timeout()获取接收器的超时配置。- Returns:
- 超时对象
-
close
推送缓冲数据到最终目标并释放资源。关闭后不可再次写入,可安全多次关闭。- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- 如果关闭失败
-