Java Code Examples for org.nustaq.serialization.FSTConfiguration#asByteArray()
The following examples show how to use
org.nustaq.serialization.FSTConfiguration#asByteArray() .
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 |
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: FSTSerializer.java From Thunder with Apache License 2.0 | 5 votes |
public static <T> byte[] serialize(FSTConfiguration fst, T object) { if (object == null) { throw new SerializerException("Object is null"); } return fst.asByteArray(object); }
Example 3
Source File: Serializer.java From meghanada-server with GNU General Public License v3.0 | 4 votes |
public static byte[] asByte(Object obj) { FSTConfiguration fst = getFST(); return fst.asByteArray(obj); }
Example 4
Source File: TemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> T deepCopyPlain(T t) { FSTConfiguration fastSerialConfig = FSTConfiguration.createDefaultConfiguration(); byte[] bytes = fastSerialConfig.asByteArray(t); return (T)fastSerialConfig.asObject(bytes); }