Here you can find the source of deserializeObject(String dir)
public static Object deserializeObject(String dir) throws IOException, ClassNotFoundException
//package com.java2s; /**/* w ww .j av a 2s. c om*/ * Musite * Copyright (C) 2010 Digital Biology Laboratory, University Of Missouri * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.util.zip.GZIPInputStream; import java.util.zip.ZipInputStream; public class Main { public static Object deserializeObject(String dir) throws IOException, ClassNotFoundException { if (dir == null) { throw new NullPointerException(); } FileInputStream fis = new FileInputStream(dir); ObjectInputStream in; if (dir.toLowerCase().endsWith(".gz")) { GZIPInputStream gzis = new GZIPInputStream(fis); in = new ObjectInputStream(gzis); } else if (dir.toLowerCase().endsWith(".zip")) { ZipInputStream zis = new ZipInputStream(fis); in = new ObjectInputStream(zis); } else { in = new ObjectInputStream(fis); } Object obj = in.readObject(); in.close(); return obj; } public static Object deserializeObject(String dir, String format) throws IOException, ClassNotFoundException { if (dir == null) { throw new NullPointerException(); } FileInputStream fis = new FileInputStream(dir); ObjectInputStream in; if (format.equalsIgnoreCase("gz")) { GZIPInputStream gzis = new GZIPInputStream(fis); in = new ObjectInputStream(gzis); } else if (format.equalsIgnoreCase("zip")) { ZipInputStream zis = new ZipInputStream(fis); in = new ObjectInputStream(zis); } else { in = new ObjectInputStream(fis); } Object obj = in.readObject(); in.close(); return obj; } }