List of utility methods to do Serializable Serialize
void | serializeObject(File inFile, Serializable inObject) serialize Object serializeObject(new FileOutputStream(inFile), inObject, true);
|
byte[] | serializeObject(Serializable cds) serialize Object ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] data = null; try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(cds); data = baos.toByteArray(); oos.close(); } catch (Exception e) { ... |
String | serializeObject(Serializable o) Write the object to a Base64 string. if (o == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o); oos.close(); return Base64.getEncoder().encodeToString(baos.toByteArray()); |
void | serializeObject(Serializable obj, String filename) serialize Object try { FileOutputStream fos = new FileOutputStream(filename); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(obj); os.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); ... |
byte[] | serializeObject(Serializable ser) Serialize an object into a byte array if (ser == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(ser); byte[] retval = baos.toByteArray(); return retval; |
byte[] | serializeObject(Serializable serializable) serialize Object byte[] base64EncodedSerializedObject = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(serializable); oos.close(); base64EncodedSerializedObject = Base64.getEncoder().encode(baos.toByteArray()); } catch (Exception ex) { ... |
void | serializeObjectToFile(File targetFile, Serializable serializable) serialize Object To File FileOutputStream fileOutputStream = null; ObjectOutputStream objectOutputStream = null; try { fileOutputStream = new FileOutputStream(targetFile); try { objectOutputStream = new ObjectOutputStream(fileOutputStream); objectOutputStream.writeObject(serializable); } catch (IOException e) { ... |