Class NBTReader
java.lang.Object
de.pauleff.formats.binary.NBTReader
- All Implemented Interfaces:
INBTReader,AutoCloseable
Class for handling the parsing and formatting of a Java NBT file.
- Author:
- Paul Ferlitz
-
Constructor Summary
ConstructorsConstructorDescriptionNBTReader(DataInputStream dis) Create a reader by passing it aDataInputStream.Create a reader by passing it the target NBT file. -
Method Summary
Modifier and TypeMethodDescriptionbyteArrayToDataInputStream(byte[] chunkData) Converts a byte array into a position-tracking DataInputStream for NBT reading.voidclose()Method to close the reader.read()Parses the NBT file and returns the root compound tag.
-
Constructor Details
-
NBTReader
Create a reader by passing it the target NBT file.- Parameters:
nbtFile- The target NBT file.
-
NBTReader
Create a reader by passing it aDataInputStream.- Parameters:
dis- ADataInputStreamcontaining a NBT file.
-
-
Method Details
-
byteArrayToDataInputStream
Converts a byte array into a position-tracking DataInputStream for NBT reading.- Parameters:
chunkData- The byte array to convert- Returns:
- A
PositionTrackingDataInputStreamfor enhanced error reporting
-
close
Method to close the reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceINBTReader- Throws:
IOException- When encountering an error whilst closing the reader.
-
read
Parses the NBT file and returns the root compound tag. This method automatically closes the reader when parsing is complete or if an error occurs.- Specified by:
readin interfaceINBTReader- Returns:
- The root
ICompoundTagcontaining the complete NBT structure - Throws:
IOException- If the file cannot be read, is corrupted, or doesn't follow NBT specification
-