List of utility methods to do Object Serialize and Deserialize
Object | deserialized(final byte[] data) deserialized if (data == null || data.length == 0) return null; final ByteArrayInputStream bais = new ByteArrayInputStream(data); ObjectInputStream ois = null; try { ois = new ObjectInputStream(bais); return ois.readObject(); } catch (IOException e) { ... |
Object | deserializeFromString(String obj) deserialize From String byte[] b = stringToBytes(obj); ByteArrayInputStream bytes = new ByteArrayInputStream(b); ObjectInputStream stream = new ObjectInputStream(bytes); return stream.readObject(); |
void | deserializeGZip(byte[] buf, T obj) deserialize G Zip try { deserializeGZipSafe(buf, obj); } catch (Exception e) { throw new RuntimeException(e); |
T | deserializeJdk(byte[] bytes) Deserializes passed in bytes using provided class loader. ObjectInputStream in = null; try { in = new ObjectInputStream(new ByteArrayInputStream(bytes)); return (T) in.readObject(); } finally { close(in); |
Object | deSerializeObj(byte[] array) de Serialize Obj ByteArrayInputStream bis = new ByteArrayInputStream(array); ObjectInputStream ois = null; try { ois = new ObjectInputStream(bis); return ois.readObject(); } catch (Exception e) { throw new RuntimeException("deSerializeObj error", e); |
Serializable | deSerializeObject(byte[] base64SerializedObject) de Serialize Object Serializable deserializedObject = null; try { byte[] data = Base64.getDecoder().decode(base64SerializedObject); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data)); deserializedObject = (Serializable) ois.readObject(); ois.close(); } catch (Exception ex) { ex.printStackTrace(); ... |
Object | deserializeObject(String dir) deserialize Object if (dir == null) { throw new NullPointerException(); FileInputStream fis = new FileInputStream(dir); ObjectInputStream in; if (dir.toLowerCase().endsWith(".gz")) { GZIPInputStream gzis = new GZIPInputStream(fis); in = new ObjectInputStream(gzis); ... |
T | deSerializeObject(String str, Class Deserialize any object T obj = null; try { byte b[] = str.getBytes("ISO-8859-1"); ByteArrayInputStream bi = new ByteArrayInputStream(b); ObjectInputStream si = new ObjectInputStream(bi); obj = cls.cast(si.readObject()); } catch (Exception e) { e.printStackTrace(); ... |
T | deserializeObjectFromByteArray(byte[] data) Read the object from Base64 string. if (data == null) return null; ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data)); Object o = ois.readObject(); ois.close(); return (T) o; |
Object | deserializeObjectFromByteArray(byte[] theSerializedVersion) Deserialize the object that was serialized into the given byte-array. final ByteArrayInputStream bais = new ByteArrayInputStream(theSerializedVersion); final ObjectInputStream input = new ObjectInputStream(bais); return input.readObject(); |