Here you can find the source of Serialize(Object serializableObject, String filePath)
Parameter | Description |
---|---|
serializableObject | Object to serialize |
filePath | Path to save the serialized object |
Parameter | Description |
---|---|
IOException | an exception |
public static void Serialize(Object serializableObject, String filePath) throws IOException
//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(); } }