Here you can find the source of load(String filename)
public static Object load(String filename) throws ClassNotFoundException, IOException
//package com.java2s; /*/* ww w . java2s . c o m*/ * Copyright (C) 2008-2015 by Holger Arndt * * This file is part of the Universal Java Matrix Package (UJMP). * See the NOTICE file distributed with this work for additional * information regarding copyright ownership and licensing. * * UJMP is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * UJMP 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 General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with UJMP; if not, write to the * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301 USA */ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; public class Main { public static Object load(String filename) throws ClassNotFoundException, IOException { return load(new File(filename)); } public static Object load(File file) throws ClassNotFoundException, IOException { FileInputStream fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); Object o = deserialize(bis); bis.close(); fis.close(); return o; } public static Object deserialize(InputStream inputStream) throws ClassNotFoundException, IOException { ObjectInputStream in = null; try { // stream closed in the finally in = new ObjectInputStream(inputStream); return in.readObject(); } catch (ClassNotFoundException ex) { throw ex; } catch (IOException ex) { throw ex; } finally { try { if (in != null) { in.close(); } } catch (IOException ex) { // ignore close exception } } } public static Object deserialize(byte[] data) throws ClassNotFoundException, IOException { ByteArrayInputStream bis = new ByteArrayInputStream(data); Object o = deserialize(bis); return o; } }