Java Object Deserialize from File deserialize(String fname)

Here you can find the source of deserialize(String fname)

Description

deserialize

License

Open Source License

Declaration

public static Object deserialize(String fname) 

Method Source Code

//package com.java2s;
// This software is released under the 2-clause BSD license.

import java.io.*;
import java.util.zip.*;

public class Main {
    public static Object deserialize(String fname) {
        return deserialize(new File(fname), false);
    }//from w  w  w . j ava  2  s .c om

    public static Object deserialize(String fname, boolean gzipped) {
        return deserialize(new File(fname), gzipped);
    }

    public static Object deserialize(File f) {
        return deserialize(f, false);
    }

    public static Object deserialize(File f, boolean gzipped) {
        try {
            InputStream is = new FileInputStream(f);
            if (gzipped)
                is = new GZIPInputStream(is);
            ObjectInputStream ois = new ObjectInputStream(is);
            Object obj = ois.readObject();
            ois.close();
            return obj;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. deserialize(String fileName)
  2. deserialize(String filename)
  3. deserialize(String filePath)
  4. Deserialize(String filePath)
  5. deserialize(String fName)
  6. deserialize(String path)
  7. deserialize(String path)
  8. deserialize(String path)
  9. deserializeFromDisk(String filePath)