List of utility methods to do Object Serialize
byte[] | serializeObject(Object o) serialize Object ByteArrayOutputStream bos = null; ObjectOutputStream oos = null; if (o == null) { return null; try { bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); ... |
String | serializeObject(Object obj) Serialize any object String ret = ""; try { ByteArrayOutputStream bo = new ByteArrayOutputStream(); ObjectOutputStream so = new ObjectOutputStream(bo); so.writeObject(obj); so.flush(); ret = bo.toString("ISO-8859-1"); } catch (Exception e) { ... |
void | serializeObject(Object obj, String destPath) Try to save an object for quick reloading later. if (obj == null) { throw new IllegalArgumentException("Cannot serialize a null object."); FileOutputStream f; ObjectOutputStream s = null; try { f = new FileOutputStream(destPath, false); s = new ObjectOutputStream(f); ... |
void | serializeObject(Object obj, String dir) serialize Object if (obj == null || dir == null) { throw new NullPointerException(); FileOutputStream fos = new FileOutputStream(dir); ObjectOutputStream out; if (dir.endsWith(".gz")) { GZIPOutputStream gzos = new GZIPOutputStream(fos); out = new ObjectOutputStream(gzos); ... |
byte[] | serializeObject(Object object) serialize Object ByteArrayOutputStream os = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(object); } finally { oos.close(); } finally { os.close(); return os.toByteArray(); |
byte[] | serializeObject(Object object) serialize Object ObjectOutputStream objectOutputStream = null; ByteArrayOutputStream byteArrayOutputStream = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(object); return byteArrayOutputStream.toByteArray(); } catch (Exception e) { ... |
void | serializeObject(Object object, File f) serialize Object OutputStream file = new FileOutputStream(f); OutputStream buffer = new BufferedOutputStream(file); ObjectOutput output = new ObjectOutputStream(buffer); output.writeObject(object); output.close(); |
byte[] | serializeObject(Object serializedObject) compress and serialize the object Deflater deflater = new Deflater(); deflater.setStrategy(Deflater.DEFAULT_STRATEGY); deflater.setLevel(Deflater.BEST_COMPRESSION); ByteArrayOutputStream outbytes = new ByteArrayOutputStream(); DeflaterOutputStream deflating = new DeflaterOutputStream(outbytes, deflater); ObjectOutputStream out = new ObjectOutputStream(deflating); out.writeObject(serializedObject); out.close(); ... |