Java Object Save writeObject(File file, Object object)

Here you can find the source of writeObject(File file, Object object)

Description

write Object

License

Mozilla Public License

Declaration

public static void writeObject(File file, Object object) 

Method Source Code


//package com.java2s;
/*//  w  ww  . j  ava2s .  c om
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.io.File;

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

import java.io.ObjectOutputStream;

public class Main {
    public static void writeObject(File file, Object object) {
        try {
            FileOutputStream fileOut = new FileOutputStream(file);
            ObjectOutputStream out = new ObjectOutputStream(fileOut);
            out.writeObject(object);
            out.close();
            fileOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeObject(File f, Object obj)
  2. writeObject(File f, Serializable obj)
  3. writeObject(File file, Object obj)
  4. writeObject(File file, Object object)
  5. writeObject(File file, Object object)
  6. writeObject(File file, Object object)
  7. writeObject(File file, Object object)
  8. writeObject(File outFile, Object data)