Java Serialize serializeObjectToFile(Object object, String filename)

Here you can find the source of serializeObjectToFile(Object object, String filename)

Description

Serializes object into filename .

License

Open Source License

Parameter

Parameter Description
filename a parameter
object a parameter

Declaration

public static void serializeObjectToFile(Object object, String filename) 

Method Source Code

//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);
        }
    }
}

Related

  1. serializeObject(String absFilePath, Object obj)
  2. serializeObject(String path, Object e)
  3. serializeObject(T obj)
  4. serializeObjects(File oof, Object[] objectsOut)
  5. serializeObjectToFile(Object obj, File f)
  6. serializer(Object object)
  7. serializeSafe(T obj)
  8. serializeShort(short value, byte[] outbuf, int offset)
  9. serializeString(File file, String string)