List of utility methods to do Object Serialize
T | serialize(T t) serialize try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(t); oos.close(); final byte[] ba = baos.toByteArray(); baos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(ba); ... |
void | serialize(T t, String filename) Serialize t object ObjectOutputStream oos = null; try { final FileOutputStream fichier = new FileOutputStream(filename); oos = new ObjectOutputStream(fichier); oos.writeObject(t); oos.flush(); } catch (final java.io.IOException e) { e.printStackTrace(); ... |
void | serialize(T t, String path) Serialize object. serialize(t, new FileOutputStream(path));
|
byte[] | serialize(T toSerialize) Convert the given Object to a byte array which when passed to deserialize() will make the same Object. final ByteArrayOutputStream out = new ByteArrayOutputStream(128); final ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(toSerialize); oos.flush(); return out.toByteArray(); |
byte[] | serialized(final Object item) serialized if (item == null) throw new NullPointerException(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(baos); oos.writeObject(item); oos.flush(); ... |
Object | serialized(Object o) Returns the result of serializing and deserializing the argument. ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(o); out.flush(); try { return new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())).readObject(); } catch (ClassNotFoundException e) { throw unexpectedException(e); ... |
Object | serialized(Serializable original) Returns a copy of an object that is obtained by serializing the original object to a byte array then deserializing the bytes from the byte array. Object result = null; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out; try { out = new ObjectOutputStream(buffer); out.writeObject(original); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); ... |
byte[] | serializeObject(final Serializable obj) Serializes an object into a byte array. final ObjectOutputStream out; final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { out = new ObjectOutputStream(outputStream); out.writeObject(obj); } catch (final IOException e) { throw new RuntimeException(e); return outputStream.toByteArray(); |
byte[] | serializeObject(Object data) serialize Object try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(data); oos.flush(); byte[] bytes = baos.toByteArray(); oos.close(); ... |
byte[] | serializeObject(Object myObject) serialize Object try { ByteArrayOutputStream myByteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream myObjectOutputStream = new ObjectOutputStream(myByteArrayOutputStream); myObjectOutputStream.writeObject(myObject); myObjectOutputStream.close(); byte[] myResult = myByteArrayOutputStream.toByteArray(); return myResult; } catch (Exception anException) { ... |