Package com.github.kokorin.jaffree.nut
Class NutInputStream
java.lang.Object
com.github.kokorin.jaffree.nut.NutInputStream
- All Implemented Interfaces:
AutoCloseable
NutInputStream adapts InputStream and provides methods to read
Nut-specific data structures.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns next byte (if available), which will be read with any read*() method.voidclose()longbooleanReturns true if stream contains more data.intreadByte()Reads f(n) type (n fixed bits in big-endian order).byte[]readBytes(long toRead) Reads specified number of bytes.Reads null-terminated string.longreadLong()Reads f(n) type (n fixed bits in big-endian order).longReads s type (variable length value, signed).readTimestamp(int timeBaseCount) Reads t type (v coded universal timestamp).longReads v type (variable length value, unsigned).byte[]Reads vb type (variable length binary data or string).Reads vb type (variable length binary data or string).voidskipBytes(long toSkip) Skips specified number of bytes.
-
Constructor Details
-
NutInputStream
CreatesNutInputStream.- Parameters:
input- input stream
-
-
Method Details
-
getPosition
public long getPosition()- Returns:
- current position
-
readValue
Reads v type (variable length value, unsigned).- Returns:
- unsigned value, or -1 if no data
- Throws:
IOException- if any IO error
-
readSignedValue
Reads s type (variable length value, signed).- Returns:
- signed value
- Throws:
IOException- if any IO error
-
readLong
Reads f(n) type (n fixed bits in big-endian order). n == 64- Returns:
- long
- Throws:
IOException- if any IO error
-
readByte
Reads f(n) type (n fixed bits in big-endian order). n == 8- Returns:
- byte
- Throws:
IOException- if any IO error
-
readVariableString
Reads vb type (variable length binary data or string).- Returns:
- String
- Throws:
IOException- if any IO error
-
readCString
Reads null-terminated string.- Returns:
- String
- Throws:
IOException- if any IO error
-
readVariableBytes
Reads vb type (variable length binary data or string).- Returns:
- String
- Throws:
IOException- if any IO error
-
readTimestamp
Reads t type (v coded universal timestamp).- Parameters:
timeBaseCount- time base count- Returns:
- Timestamp
- Throws:
IOException- if any IO error
-
checkNextByte
Returns next byte (if available), which will be read with any read*() method.Note: position in
InputStreamisn't changed.- Returns:
- next byte, or -1 if the end of the stream is reached
- Throws:
IOException- if any IO error
-
hasMoreData
Returns true if stream contains more data.- Returns:
- next byte
- Throws:
IOException- if any IO error
-
readBytes
Reads specified number of bytes.- Parameters:
toRead- bytes to read- Returns:
- byte array
- Throws:
IOException- if any IO error
-
skipBytes
Skips specified number of bytes.- Parameters:
toSkip- bytes to skip- Throws:
IOException- if any IO error
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-