Java Object Deserialize from File deserialize(File file)

Here you can find the source of deserialize(File file)

Description

Deserialize an object from a given file

License

Open Source License

Parameter

Parameter Description
file the file to deserialize

Return

the deserialized object

Declaration

public static Object deserialize(File file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

public class Main {
    /**/*from  w w w . ja v  a  2 s .c  o m*/
     * Deserialize an object from a given file
     * 
     * @param file
     *            the file to deserialize
     * @return the deserialized object
     */
    public static Object deserialize(File file) {
        Object result = null;
        try {
            FileInputStream fileIn = new FileInputStream(file);
            ObjectInputStream in = new ObjectInputStream(fileIn);
            result = in.readObject();
            in.close();
            fileIn.close();
        } catch (ClassNotFoundException | IOException e) {
            e.printStackTrace();
            return null;
        }
        return result;
    }
}

Related

  1. deserialisasi(String sFile)
  2. deserialiseObject(File f)
  3. deserialization(String filePath)
  4. deserialize(File file)
  5. deserialize(File file)
  6. deserialize(File file)
  7. deserialize(File file)
  8. deserialize(File file, Class clazz)
  9. deserialize(final File file)