Java Code Examples for org.nustaq.serialization.FSTObjectInput#readObject()

The following examples show how to use org.nustaq.serialization.FSTObjectInput#readObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FstExample.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: Serializer.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
public static <T> T readObject(InputStream input, Class<T> clazz) throws Exception {
  FSTObjectInput in = getFST().getObjectInput(input);
  Object obj = in.readObject(clazz);
  input.close();
  if (isNull(obj)) {
    return null;
  }
  return clazz.cast(obj);
}
 
Example 3
Source File: Parameters.java    From htm.java with GNU Affero General Public License v3.0 4 votes vote down vote up
public Parameters readForNetwork(FSTObjectInput in) throws Exception {
    Parameters result = (Parameters)in.readObject(Parameters.class);
    return result;
}