-
Notifications
You must be signed in to change notification settings - Fork 0
GravSerializer
A quick overview of the available methods
Supported datatypes:
- All Java primitives
- Byte array, Boolean array
- String
- UUID
- VarInt
- BigInteger
- Other serializer
Method names for reading and writing are in the form read, write, (e.g. readInt, writeInt)
Note: int, long, float, and double support both big- and little-endian serialization by providing a boolean as the second argument. The default is big-endian.
For any of the above types, and more, readObject and writeObject can be used, although it uses an additional byte to store object type. A list of types supported by read/writeObject can be found here
To read data from a stream into a GravSerializer, simply call one of the two constructors for streams:
-
GravSerializer(InputStream)No compression -
GravSerializer(InputStream, Compressor)Read data and decompress using the provided compressor
The constructor will read data from the stream until no more bytes are available
To write data into an OutputStream, use one of the following two methods:
-
GravSerializer#writeToStream(OutputStream)Write data to the output stream without compression -
GravSerializer#writeToStream(OutputStream, Compressor)Compress data and write into the output stream