Here you can find the source of writeObject(Object object, File destinationFile)
Parameter | Description |
---|---|
object | the object |
destinationFile | the destination file |
Parameter | Description |
---|---|
IOException | exception thrown whenever an error occurred whilewriting the file |
public static void writeObject(Object object, File destinationFile) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**//from w w w.j a v a 2 s . c om * Writes an object to the destination file. * * @param object the object * @param destinationFile the destination file * @throws IOException exception thrown whenever an error occurred while * writing the file */ public static void writeObject(Object object, File destinationFile) throws IOException { FileOutputStream fos = new FileOutputStream( destinationFile.getAbsoluteFile()); try { BufferedOutputStream bos = new BufferedOutputStream(fos); try { ObjectOutputStream oos = new ObjectOutputStream(bos); try { oos.writeObject(object); } finally { oos.close(); } } finally { bos.close(); } } finally { fos.close(); } } }