Here you can find the source of deserializeFromFile(File file)
Parameter | Description |
---|---|
file | File source |
Parameter | Description |
---|---|
IOException | an exception |
public static Object deserializeFromFile(File file) throws IOException
//package com.java2s; /* IoUtils/*from www . j av a 2s . c o m*/ * * Created on Dec 8, 2004 * * Copyright (C) 2004 Internet Archive. * * This file is part of the Heritrix web crawler (crawler.archive.org). * * Heritrix is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * any later version. * * Heritrix is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with Heritrix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { /** * Utility method to deserialize an Object from given File. * * @param file File source * @return deserialized Object * @throws IOException */ public static Object deserializeFromFile(File file) throws IOException { ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file))); Object object; try { object = ois.readObject(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block throw new RuntimeException(e); } ois.close(); return object; } }