Class PeekSource

java.lang.Object
org.miaixz.bus.core.io.source.PeekSource
All Implemented Interfaces:
Closeable, AutoCloseable, Source

public class PeekSource extends Object implements Source
一个Source,它可以窥视上游的BufferSource并允许读取和 展开缓冲数据而不使用它 这是通过请求额外的数据吗 如果需要,则复制上游源文件,如果需要,则从上游源文件的内部缓冲区复制 此源还维护其上游缓冲区的起始位置的快照 每次读取时验证 如果从上游缓冲区读取,则此源将变为 无效,在以后的读取中抛出IllegalStateException
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

  • Method Details

    • read

      public long read(Buffer sink, long byteCount) throws IOException
      Description copied from interface: Source
      从中删除至少1个字节,最多为byteCount字节, 并将它们 附加到sink。返回读取的字节数,如果该源已耗尽,则返回-1
      Specified by:
      read in interface Source
      Parameters:
      sink - 缓冲
      byteCount - 长度大小
      Returns:
      the long
      Throws:
      IOException - 异常
    • timeout

      public Timeout timeout()
      Description copied from interface: Source
      返回此源的超时时间.
      Specified by:
      timeout in interface Source
      Returns:
      超时时间
    • close

      public void close() throws IOException
      Description copied from interface: Source
      关闭此源并释放此源持有的资源. 读取闭源是一个错误。多次关闭源是安全的.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Source
      Throws:
      IOException - 异常