Java Object Serialize Serialize(Object serializableObject, String filePath)

Here you can find the source of Serialize(Object serializableObject, String filePath)

Description

Serializes an object to the specified file path

License

Open Source License

Parameter

Parameter Description
serializableObject Object to serialize
filePath Path to save the serialized object

Exception

Parameter Description
IOException an exception

Declaration

public static void Serialize(Object serializableObject, String filePath) throws IOException 

Method Source Code

//package com.java2s;

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

import java.io.ObjectOutputStream;

public class Main {
    /**/*from   w  w  w . j a  v  a  2 s . com*/
     * Serializes an object to the specified file path
     * @param serializableObject Object to serialize
     * @param filePath Path to save the serialized object
     * @throws IOException
     */
    public static void Serialize(Object serializableObject, String filePath) throws IOException {
        FileOutputStream fileStream = new FileOutputStream(filePath);
        ObjectOutputStream objectStream = new ObjectOutputStream(fileStream);
        objectStream.writeObject(serializableObject);
        objectStream.flush();
        objectStream.close();
    }
}

Related

  1. serialize(Object object, boolean zipped)
  2. serialize(Object object, File file)
  3. serialize(Object object, File file)
  4. serialize(Object object, String fileName)
  5. serialize(Object object, String path)
  6. serialize(Object state)
  7. serialize(Object value)
  8. serialize(Object value)
  9. serialize(S value)