Java Object Deserialize from File deserialize(File file)

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

Description

deserialize

License

Open Source License

Declaration

public static Object deserialize(File file) throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
import java.io.BufferedInputStream;

import java.io.Closeable;
import java.io.File;

import java.io.FileInputStream;

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

public class Main {
    public static Object deserialize(File file) throws IOException, ClassNotFoundException {

        ObjectInputStream in = null;
        try {//w w w .  ja v  a2  s . com
            in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
            return in.readObject();
        } finally {
            if (in != null)
                in.close();
        }
    }

    public static Object deserialize(InputStream stream) throws IOException, ClassNotFoundException {

        ObjectInputStream in = null;
        try {
            in = new ObjectInputStream(stream);
            return in.readObject();
        } finally {
            if (in != null)
                in.close();
        }
    }

    public static void close(Closeable in) {

        try {
            if (in != null) {
                in.close();
            }
        } catch (IOException e) {
        }
    }
}

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)