Class NutInputStream

java.lang.Object
com.github.kokorin.jaffree.nut.NutInputStream
All Implemented Interfaces:
AutoCloseable

public class NutInputStream extends Object implements AutoCloseable
NutInputStream adapts InputStream and provides methods to read Nut-specific data structures.
  • Constructor Details

  • Method Details

    • getPosition

      public long getPosition()
      Returns:
      current position
    • readValue

      public long readValue() throws IOException
      Reads v type (variable length value, unsigned).
      Returns:
      unsigned value, or -1 if no data
      Throws:
      IOException - if any IO error
    • readSignedValue

      public long readSignedValue() throws IOException
      Reads s type (variable length value, signed).
      Returns:
      signed value
      Throws:
      IOException - if any IO error
    • readLong

      public long readLong() throws IOException
      Reads f(n) type (n fixed bits in big-endian order). n == 64
      Returns:
      long
      Throws:
      IOException - if any IO error
    • readByte

      public int readByte() throws IOException
      Reads f(n) type (n fixed bits in big-endian order). n == 8
      Returns:
      byte
      Throws:
      IOException - if any IO error
    • readVariableString

      public String readVariableString() throws IOException
      Reads vb type (variable length binary data or string).
      Returns:
      String
      Throws:
      IOException - if any IO error
    • readCString

      public String readCString() throws IOException
      Reads null-terminated string.
      Returns:
      String
      Throws:
      IOException - if any IO error
    • readVariableBytes

      public byte[] readVariableBytes() throws IOException
      Reads vb type (variable length binary data or string).
      Returns:
      String
      Throws:
      IOException - if any IO error
    • readTimestamp

      public Timestamp readTimestamp(int timeBaseCount) throws IOException
      Reads t type (v coded universal timestamp).
      Parameters:
      timeBaseCount - time base count
      Returns:
      Timestamp
      Throws:
      IOException - if any IO error
    • checkNextByte

      public int checkNextByte() throws IOException
      Returns next byte (if available), which will be read with any read*() method.

      Note: position in InputStream isn't changed.

      Returns:
      next byte, or -1 if the end of the stream is reached
      Throws:
      IOException - if any IO error
    • hasMoreData

      public boolean hasMoreData() throws IOException
      Returns true if stream contains more data.
      Returns:
      next byte
      Throws:
      IOException - if any IO error
    • readBytes

      public byte[] readBytes(long toRead) throws IOException
      Reads specified number of bytes.
      Parameters:
      toRead - bytes to read
      Returns:
      byte array
      Throws:
      IOException - if any IO error
    • skipBytes

      public void skipBytes(long toSkip) throws IOException
      Skips specified number of bytes.
      Parameters:
      toSkip - bytes to skip
      Throws:
      IOException - if any IO error
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException