Here you can find the source of serialize(Object object, File file)
Parameter | Description |
---|---|
object | the object to serialize |
file | the file to serialize the object |
public static void serialize(Object object, File file)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { /**//from www.j a v a 2 s . c om * Serialise a given object into a given file * * @param object * the object to serialize * @param file * the file to serialize the object */ public static void serialize(Object object, File file) { try { FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); try { oos.writeObject(object); oos.flush(); } finally { try { oos.close(); } finally { fos.close(); } } } catch (IOException e) { e.printStackTrace(); } } }