Here you can find the source of serializeObjectToFile(Object object, String filename)
Parameter | Description |
---|---|
filename | a parameter |
object | a parameter |
public static void serializeObjectToFile(Object object, String filename)
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { /**//from ww w . j a v a 2s .co m * Serializes {@code object} into {@code filename}. * * @param filename * @param object */ public static void serializeObjectToFile(Object object, String filename) { FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); out.writeObject(object); out.close(); } catch (IOException ex) { ex.printStackTrace(); System.exit(1); } } }