List of utility methods to do Serialize
byte[] | serializeInt2MinLE(int value) Returns the minimum bytes needed for the given value to encoded it in little-endian format. if (value < 0) { throw new IllegalArgumentException("Negative input value"); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(4); do { byteStream.write(value & 0xFF); value >>= 8; } while (value != 0); ... |
int | serializeIntLE(int value, byte[] outbuf, int offset) serialize Int LE outbuf[offset++] = (byte) (value); outbuf[offset++] = (byte) (value >> 8); outbuf[offset++] = (byte) (value >> 16); outbuf[offset++] = (byte) (value >> 24); return offset; |
byte[] | serializeJdk(Object obj) Serializes a given object into byte array. ByteArrayOutputStream byteOut = null; ObjectOutputStream objOut = null; try { byteOut = new ByteArrayOutputStream(512); objOut = new ObjectOutputStream(byteOut); objOut.writeObject(obj); objOut.flush(); return byteOut.toByteArray(); ... |
ByteArrayOutputStream | serializeMock(Object mock) serialize Mock ByteArrayOutputStream serialized = new ByteArrayOutputStream(); new ObjectOutputStream(serialized).writeObject(mock); return serialized; |
B | serializeObject(B b) serialize Object ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(b); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); return (B) ois.readObject(); |
byte[] | serializeObject(final Object object) serialize Object ObjectOutput out = null; byte[] buf = null; if (object == null) { return null; try { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); out = new ObjectOutputStream(bos); ... |
void | serializeObject(String absFilePath, Object obj) serialize Object FileOutputStream fileStream = null; ObjectOutputStream objStream = null; try { fileStream = new FileOutputStream(absFilePath); objStream = new ObjectOutputStream(fileStream); objStream.writeObject(obj); } finally { if (objStream != null) ... |
void | serializeObject(String path, Object e) serialize Object OutputStream os; try { os = new FileOutputStream(path); ObjectOutput oo = new ObjectOutputStream(os); oo.writeObject(e); oo.close(); } catch (Exception e1) { e1.printStackTrace(); ... |
byte[] | serializeObject(T obj) Seralize a Serializable object. try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oo = new ObjectOutputStream(bos)) { oo.writeObject(obj); oo.flush(); return bos.toByteArray(); |
void | serializeObjects(File oof, Object[] objectsOut) serialize Objects FileOutputStream fos = new FileOutputStream(oof); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(objectsOut); oos.close(); |