Interface DataReader

All Known Implementing Classes:
ByteArrayDataReader, LinkedDataReader

public interface DataReader
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte[]
     
  • Method Summary

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

    • EMPTY_BYTES

      static final byte[] EMPTY_BYTES
  • Method Details

    • read

      byte read() throws NoMoreDataException
      读取单个字节 (指针会移动) 当没有更多的数据时会抛出异常
      Returns:
      byte
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • read

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

      void read(DataConsumer dataConsumer, int maxLength) throws NoMoreDataException
      向 dataConsumer 写入指定长度字节 (指针会移动) 当没有更多的数据时会抛出异常
      Parameters:
      maxLength - 最大长度
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • peek

      byte peek() throws NoMoreDataException
      向 dataConsumer 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
      Returns:
      byte
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • peek

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

      void peek(DataConsumer dataConsumer, int maxLength) throws NoMoreDataException
      向 outputStream 写入指定长度字节 (指针不会移动) 当没有更多的数据时会抛出异常
      Parameters:
      maxLength - 最大长度
      Throws:
      NoMoreDataException - 没有更多数据时抛出
    • indexOf

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

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

      void skip(int length)
      向后移动指定字节
      Parameters:
      length - 移动长度
    • readUntil

      default byte[] readUntil(byte b) throws NoMatchFoundException
      读取 直到 找到匹配的字节 (指针会移动)
      Parameters:
      b - 指定字节
      Returns:
      bytes
      Throws:
      NoMatchFoundException - 没有匹配时抛出
    • readUntil

      default byte[] readUntil(byte[] b) throws NoMatchFoundException
      读取 直到 找到匹配的字节 (指针会移动)
      Parameters:
      b - 指定字节
      Returns:
      bytes
      Throws:
      NoMatchFoundException - 没有匹配时抛出
    • peekUntil

      default byte[] peekUntil(byte b) throws NoMatchFoundException
      读取 直到 找到匹配的字节 (指针不会移动)
      Parameters:
      b - 指定字节
      Returns:
      bytes
      Throws:
      NoMatchFoundException - 没有匹配时抛出
    • peekUntil

      default byte[] peekUntil(byte[] b) throws NoMatchFoundException
      读取 直到 找到匹配的字节 (指针不会移动)
      Parameters:
      b - 指定字节
      Returns:
      bytes
      Throws:
      NoMatchFoundException - 没有匹配时抛出