public static void writeObject ( File file , Object object ) throws IOException { FileOutputStream fileOut = new FileOutputStream ( file ) ; ObjectOutputStream out = new ObjectOutputStream ( new BufferedOutputStream ( fileOut ) ) ; try { out . writeObject ( object ) ; out . flush ( ) ; // Force sync fileOut . getFD ( ) . sync ( ) ; } finally { IoUtils . safeClose ( out ) ; } }
To store an object in a quick & dirty way .