Java Object Deserialize from File deserializeFromFile(String path)

Here you can find the source of deserializeFromFile(String path)

Description

deserialize From File

License

Open Source License

Declaration

public static <T extends Serializable> T deserializeFromFile(String path)
            throws IOException, ClassNotFoundException 

Method Source Code

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

import java.io.FileInputStream;

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

import java.io.Serializable;

public class Main {
    public static <T extends Serializable> T deserializeFromFile(String path)
            throws IOException, ClassNotFoundException {
        FileInputStream fileIn = new FileInputStream(path);
        T e = deserialize(fileIn);//w ww.j  a v a  2s.co  m
        fileIn.close();
        return e;
    }

    public static <T extends Serializable> T deserialize(InputStream is)
            throws IOException, ClassNotFoundException {
        ObjectInputStream in = new ObjectInputStream(is);
        @SuppressWarnings("unchecked")
        T e = (T) in.readObject();
        in.close();
        return e;
    }
}

Related

  1. deserialize(String path)
  2. deserialize(String path)
  3. deserializeFromDisk(String filePath)
  4. deserializeFromFile(File file)
  5. deserializeFromFile(File file)
  6. deserializeFromFile(String path)
  7. deserializeMap(File file)
  8. deserializeMyContext(String path)
  9. deserializeObject(String classpathFileName)