Here you can find the source of load(File file)
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
ClassNotFoundException | an exception |
public static Object load(File file) throws IOException, ClassNotFoundException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { /**// w w w . j a va 2 s . co m * @param file * @return Object * @throws IOException * @throws ClassNotFoundException */ public static Object load(File file) throws IOException, ClassNotFoundException { FileInputStream fis = null; ObjectInputStream ois = null; try { fis = new FileInputStream(file); ois = new ObjectInputStream(fis); return ois.readObject(); } finally { try { if (ois != null) { ois.close(); } if (fis != null) { fis.close(); } } catch (IOException e) { // Do Nothing } } } }