Here you can find the source of deserialize(File file)
Parameter | Description |
---|---|
file | the file to read. |
Parameter | Description |
---|---|
IOException | an exception |
ClassNotFoundException | an exception |
public static Serializable deserialize(File file) throws IOException, ClassNotFoundException
//package com.java2s; /**/*from ww w. j a va2s. c o m*/ * This software is released as part of the Pumpernickel project. * * All com.pump resources in the Pumpernickel project are distributed under the * MIT License: * https://raw.githubusercontent.com/mickleness/pumpernickel/master/License.txt * * More information about the Pumpernickel project is available here: * https://mickleness.github.io/pumpernickel/ */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; import java.util.zip.GZIPInputStream; public class Main { /** * Deserialize a serialized, compressed object at the file path provided. * * See {@link #serialize(Serializable, File)} * * @param file * the file to read. * @return the deserialized data. * @throws IOException * @throws ClassNotFoundException */ public static Serializable deserialize(File file) throws IOException, ClassNotFoundException { try (FileInputStream fileIn = new FileInputStream(file)) { try (GZIPInputStream zipIn = new GZIPInputStream(fileIn)) { try (ObjectInputStream objIn = new ObjectInputStream(zipIn)) { return (Serializable) objIn.readObject(); } } } } }