DataSerializer, serialize and deserialize data !
Java
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
doc
src
.gitignore
DataSerializer.iml
README.md
pom.xml

README.md

DataSerializer

Serialize and Deserialize data !

How to use an Serializer ?

First, create A FileSerializerBuilder object and invoke "get" method to return the FileSerializer:
Example:

// Create first an builder with the compilation type and cast it
JsonFileSerializer serializer = (JsonFileSerializer) new FileSerializerBuilder().type(CompilationType.JSON).get();
// write your data, Warning: the json serializer need keys !
serializer.writeObject("int", 192);
serializer.writeObject("string", "test");
serializer.writeObject("float", 42.5f);
// and for creating the file, juste call "compile"
// method with the target file
long execTime = serializer.compile(new File("data")); // You can get the time of the building task
// Don't forget to close the serializer !
serializer.close();

How to use an Deserializer ?

First, create A FileDeserializerBuilder object and invoke "get" method to return the FileSerializer:
Example:

// Create first an builder with the compilation type and the file and cast it
JsonFileDeserializer deserializer = (JsonFileDeserializer) new FileDeserializerBuilder().type(CompilationType.JSON).file(new File("data")).get();
// read your data, the Deserializer has DataInputStream as superclass, Warning: the json deserializer need keys !
int resultInt = deserializer.readInt("int");
String resultString = deserializer.readUTF("string");
float resultFloat = deserializer.readFloat("float");
// Don't forget to close the deserializer !
serializer.close();

Tip: You can use a "try-catch-with-ressources" instead calling close method.

Installation

Lastest Version: download

Maven Integration

Be sure to replace the VERSION key below with the latest version !

<repository>
    <id>oss-sonatype</id>
    <name>oss-sonatype</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

<dependency>
    <groupId>com.github.sofianelecubeur</groupId>
    <artifactId>DataSerializer</artifactId>
    <version>VERSION</version>
</dependency>

Documentation

Find the JavaDoc here: javadoc