Module bus.core

Class DeflaterSink

java.lang.Object
org.miaixz.bus.core.io.sink.DeflaterSink
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, Sink

public class DeflaterSink extends Object implements Sink
使用 Deflater 进行压缩的接收器,立即压缩并写入缓冲数据,调用 flush 会导致压缩率降低。
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Summary

    Constructors
    Constructor
    Description
    DeflaterSink(Sink sink, Deflater deflater)
    构造方法,使用指定的接收器和压缩器。
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    关闭接收器,完成压缩并释放资源。
    void
    刷新缓冲区,立即压缩并写入所有数据。
    获取底层接收器的超时配置。
    返回对象的字符串表示。
    void
    write(Buffer source, long byteCount)
    从源缓冲区读取指定字节数并压缩写入接收器。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DeflaterSink

      public DeflaterSink(Sink sink, Deflater deflater)
      构造方法,使用指定的接收器和压缩器。
      Parameters:
      sink - 底层接收器
      deflater - 压缩器
  • Method Details

    • write

      public void write(Buffer source, long byteCount) throws IOException
      从源缓冲区读取指定字节数并压缩写入接收器。
      Specified by:
      write in interface Sink
      Parameters:
      source - 数据源缓冲区
      byteCount - 要读取的字节数
      Throws:
      IOException - 如果写入失败
    • flush

      public void flush() throws IOException
      刷新缓冲区,立即压缩并写入所有数据。
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface Sink
      Throws:
      IOException - 如果刷新失败
    • close

      public void close() throws IOException
      关闭接收器,完成压缩并释放资源。
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Sink
      Throws:
      IOException - 如果关闭失败
    • timeout

      public Timeout timeout()
      获取底层接收器的超时配置。
      Specified by:
      timeout in interface Sink
      Returns:
      超时对象
    • toString

      public String toString()
      返回对象的字符串表示。
      Overrides:
      toString in class Object
      Returns:
      字符串表示,包含类名和底层接收器信息