List of utility methods to do Object Save
void | writeObjectToFile(File file, Object o) write Object To File ObjectOutputStream oop = new ObjectOutputStream(new FileOutputStream(file)); oop.writeObject(o); oop.close(); |
void | writeObjectToFile(File file, Object obj) write Object To File FileOutputStream fOS = new FileOutputStream(file); ObjectOutputStream oOS = new ObjectOutputStream(fOS); oOS.writeObject(obj); oOS.flush(); oOS.close(); |
void | writeObjectToFile(final Object o, final File dir) Utility function to serialize an object to a file in current checkpoint dir. writeObjectToFile(o, null, dir); |
File | writeObjectToFile(Object o, File file, boolean append) Write an object to a specified File. ObjectOutputStream oos = new ObjectOutputStream( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file, append)))); oos.writeObject(o); oos.close(); return file; |
File | writeObjectToFile(Object o, String filename) Write object to a file with the specified name. return writeObjectToFile(o, new File(filename)); |
File | writeObjectToFile(Object o, String fileName) Serialize java object to a file. File outFile = new File(fileName); OutputStream outputStream = new FileOutputStream(outFile); if (fileName.endsWith(".gz")) { outputStream = new GZIPOutputStream(outputStream); outputStream = new BufferedOutputStream(outputStream); ObjectOutputStream oos = new ObjectOutputStream(outputStream); oos.writeObject(o); ... |
boolean | writeObjectToFile(Object obj, File f) Writes a generic object to a file try { FileOutputStream fout = new FileOutputStream(f); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(obj); oos.close(); } catch (Exception e) { System.out.println("Error writing Object to file: " + e.getMessage()); return false; ... |
boolean | writeObjectToFile(Object obj, String fileName) Writes an Object to a file. return writeObjectToFile(obj, new File(fileName)); |
void | writeObjectToFile(Object obj, String path) write Object To File writeObjectToFile(obj, new File(path));
|
void | writeObjectToFile(Object object, File file) write Object To File if (!file.exists()) { file.createNewFile(); FileWriter writer = new FileWriter(file); writer.write(gson.toJson(object)); writer.close(); |