Java Object Save writeObject(Object obj, File path)

Here you can find the source of writeObject(Object obj, File path)

Description

write Object

License

Open Source License

Declaration

public static void writeObject(Object obj, File path) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.ObjectOutputStream;

public class Main {
    public static void writeObject(Object obj, File path) {
        ObjectOutputStream out = null;
        try {/*from  ww  w  .j av  a 2 s.  c om*/
            out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(path)));
            out.writeObject(obj);
            out.close();
        } catch (IOException e) {
            System.err.println("Failed to write filename " + path);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                }
            }
        }
    }
}

Related

  1. writeObject(Object data, String filename)
  2. writeObject(Object i)
  3. writeObject(Object o, File f)
  4. writeObject(Object o, File path)
  5. writeObject(Object o, ObjectOutput dos)
  6. writeObject(Object obj, ObjectOutput out)
  7. writeObject(Object object)
  8. writeObject(Object object, File destinationFile)
  9. writeObject(Object object, String path)