public static boolean writeObjectToFile ( Object obj , File f ) { 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 ; } return true ; }
Writes a generic object to a file