Java Object Deserialize from File deserialize(final File file)

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

Description

deserialize

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static <O> O deserialize(final File file) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.io.IOException;

import java.io.ObjectInputStream;

public class Main {
    @SuppressWarnings("unchecked")
    public static <O> O deserialize(final File file) {
        O o = null;//  w ww  . j a  v  a  2 s  . c om
        try {
            final FileInputStream fileIn = new FileInputStream(file);
            final ObjectInputStream in = new ObjectInputStream(fileIn);
            o = (O) in.readObject();
            in.close();
            fileIn.close();
            return o;
        } catch (IOException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. deserialize(File file)
  2. deserialize(File file)
  3. deserialize(File file)
  4. deserialize(File file)
  5. deserialize(File file, Class clazz)
  6. deserialize(final String path)
  7. deserialize(String filename)
  8. deserialize(String fileName)
  9. deserialize(String filename)