Here you can find the source of Deserialize(String filePath)
Parameter | Description |
---|---|
filePath | Path of the serialized object |
Parameter | Description |
---|---|
IOException | an exception |
ClassNotFoundException | an exception |
public static Object Deserialize(String filePath) throws IOException, ClassNotFoundException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { /**/*from w ww .j av a 2 s. com*/ * Deserializes an object * @param filePath Path of the serialized object * @return * @throws IOException * @throws ClassNotFoundException */ public static Object Deserialize(String filePath) throws IOException, ClassNotFoundException { Object result = null; if (!new File(filePath).exists()) return result; FileInputStream fileStream = new FileInputStream(filePath); ObjectInputStream objectStream = new ObjectInputStream(fileStream); result = objectStream.readObject(); return result; } }