Package org.miaixz.bus.core.io.sink
Interface Sink
- 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
Modifier and TypeMethodDescriptionvoidclose()Pushes all buffered bytes to their final destination and releases the resources held by this sink.voidflush()Pushes all buffered bytes to their final destination.timeout()Returns the timeout for this sink.voidRemovesbyteCountbytes fromsourceand appends them to this.
-
Method Details
-
write
RemovesbyteCountbytes fromsourceand appends them to this.- Throws:
IOException
-
flush
Pushes all buffered bytes to their final destination.- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
timeout
Timeout timeout()Returns the timeout for this sink.- Returns:
- the
Timeout
-
close
Pushes all buffered bytes to their final destination and releases the resources held by this sink. It is an error to write a closed sink. It is safe to close a sink more than once.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-