Class LinkedDataReader

java.lang.Object
cool.scx.io.LinkedDataReader
All Implemented Interfaces:
DataReader

public class LinkedDataReader extends Object implements DataReader
  • Field Summary

    Fields inherited from interface cool.scx.io.DataReader

    EMPTY_BYTES
  • Constructor Summary

    Constructors
    Constructor
    Description
    LinkedDataReader(Supplier<byte[]> bytesSupplier)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    int
    indexOf(byte b)
    查找 指定字节 第一次出现的 index (指针不会移动)
    int
    indexOf(byte[] pattern)
    查找 指定字节数组 第一次出现的 index (指针不会移动)
    byte
    读取单个字节 (指针不会移动) 当没有更多的数据时会抛出异常
    byte[]
    peek(int maxLength)
    读取指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
    void
    peek(OutputStream outputStream, int maxLength)
    向 outputStream 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
    boolean
     
    byte
    读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常
    byte[]
    read(int maxLength)
    读取字节 (指针会移动) 当没有更多的数据时会抛出异常
    void
    read(OutputStream outputStream, int maxLength)
    向 outputStream 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常
    void
    skip(int length)
    向后移动指定字节

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface cool.scx.io.DataReader

    peekUntil, peekUntil, readUntil, readUntil
  • Constructor Details

    • LinkedDataReader

      public LinkedDataReader(Supplier<byte[]> bytesSupplier)
  • Method Details

    • pullData

      public boolean pullData()
    • ensureAvailable

      public void ensureAvailable()
    • read

      public byte read() throws NoMoreDataException
      Description copied from interface: DataReader
      读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常
      Specified by:
      read in interface DataReader
      Returns:
      byte
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • read

      public byte[] read(int maxLength) throws NoMoreDataException
      Description copied from interface: DataReader
      读取字节 (指针会移动) 当没有更多的数据时会抛出异常
      Specified by:
      read in interface DataReader
      Parameters:
      maxLength - 最大长度
      Returns:
      bytes
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • read

      public void read(OutputStream outputStream, int maxLength) throws NoMoreDataException
      Description copied from interface: DataReader
      向 outputStream 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常
      Specified by:
      read in interface DataReader
      Parameters:
      maxLength - 最大长度
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • peek

      public byte peek() throws NoMoreDataException
      Description copied from interface: DataReader
      读取单个字节 (指针不会移动) 当没有更多的数据时会抛出异常
      Specified by:
      peek in interface DataReader
      Returns:
      byte
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • peek

      public byte[] peek(int maxLength) throws NoMoreDataException
      Description copied from interface: DataReader
      读取指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
      Specified by:
      peek in interface DataReader
      Parameters:
      maxLength - 最大长度
      Returns:
      byte
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • peek

      public void peek(OutputStream outputStream, int maxLength) throws NoMoreDataException
      Description copied from interface: DataReader
      向 outputStream 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
      Specified by:
      peek in interface DataReader
      Parameters:
      maxLength - 最大长度
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • indexOf

      public int indexOf(byte b) throws NoMatchFoundException
      Description copied from interface: DataReader
      查找 指定字节 第一次出现的 index (指针不会移动)
      Specified by:
      indexOf in interface DataReader
      Parameters:
      b - 指定字节
      Returns:
      index 或者 -1 (未找到)
      Throws:
      NoMatchFoundException - 没有匹配时抛出
    • indexOf

      public int indexOf(byte[] pattern) throws NoMatchFoundException
      Description copied from interface: DataReader
      查找 指定字节数组 第一次出现的 index (指针不会移动)
      Specified by:
      indexOf in interface DataReader
      Parameters:
      pattern - 指定字节数组
      Returns:
      index 或者 -1 (未找到)
      Throws:
      NoMatchFoundException - 没有匹配时抛出
    • skip

      public void skip(int length)
      Description copied from interface: DataReader
      向后移动指定字节
      Specified by:
      skip in interface DataReader
      Parameters:
      length - 移动长度