Here you can find the source of saveObject(String filename, Object obj)
Parameter | Description |
---|---|
filename | a parameter |
obj | a parameter |
public static boolean saveObject(String filename, Object obj)
//package com.java2s; //License from project: Open Source License import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { /**//w w w. ja v a 2 s . c o m * * @param filename * @param obj * @return */ public static boolean saveObject(String filename, Object obj) { try { FileOutputStream fileOut = new FileOutputStream(filename); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(obj); out.close(); fileOut.close(); return true; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return false; } }