Skip to content

GravSerializer

Matthew Lack edited this page Oct 2, 2021 · 4 revisions

A quick overview of the available methods

Reading/Writing Data

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

Working with Streams

Reading

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

Writing

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

Getting Started

Clone this wiki locally