Interface Sink

All Superinterfaces:
AutoCloseable, Closeable, Flushable
All Known Subinterfaces:
BufferSink
All Known Implementing Classes:
AssignSink, Buffer, DeflaterSink, FaultHideSink, GzipSink, RealSink

public interface Sink extends Closeable, Flushable
接收一个字节流 使用这个接口可以在任何地方编写数据 需要:到网络、存储器或内存中的缓冲区 水槽可以分层 转换接收到的数据,如压缩、加密、节流或添加协议框架 BufferSink.outputStream()使一个接收器适应outputStream
Since:
Java 17+
Author:
Kimi Liu
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Pushes all buffered bytes to their final destination and releases the resources held by this sink.
    void
    Pushes all buffered bytes to their final destination.
    Returns the timeout for this sink.
    void
    write(Buffer source, long byteCount)
    Removes byteCount bytes from source and appends them to this.
  • Method Details

    • write

      void write(Buffer source, long byteCount) throws IOException
      Removes byteCount bytes from source and appends them to this.
      Throws:
      IOException
    • flush

      void flush() throws IOException
      Pushes all buffered bytes to their final destination.
      Specified by:
      flush in interface Flushable
      Throws:
      IOException
    • timeout

      Timeout timeout()
      Returns the timeout for this sink.
      Returns:
      the Timeout
    • close

      void close() throws IOException
      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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException