Search in sources :

Example 1 with FSTObjectInput

use of org.nustaq.serialization.FSTObjectInput in project chuidiang-ejemplos by chuidiang.

the class FstExample method main.

public static void main(String[] args) throws Exception {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
    SomeMediumClass mediumClass = new SomeMediumClass();
    byte[] barray = conf.asByteArray(mediumClass);
    System.out.println(barray.length);
    SomeMediumClass object = (SomeMediumClass) conf.asObject(barray);
    System.out.println(object);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    FSTObjectOutput output = new FSTObjectOutput(outputStream);
    output.writeObject(mediumClass);
    output.close();
    FSTObjectInput input = new FSTObjectInput(new ByteArrayInputStream(outputStream.toByteArray()));
    object = (SomeMediumClass) input.readObject(SomeMediumClass.class);
    System.out.println(object);
}
Also used : FSTConfiguration(org.nustaq.serialization.FSTConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) FSTObjectOutput(org.nustaq.serialization.FSTObjectOutput) FSTObjectInput(org.nustaq.serialization.FSTObjectInput)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FSTConfiguration (org.nustaq.serialization.FSTConfiguration)1 FSTObjectInput (org.nustaq.serialization.FSTObjectInput)1 FSTObjectOutput (org.nustaq.serialization.FSTObjectOutput)1