Here you can find the source of serializeAndReadObject(File envHome, Object object)
public static Object serializeAndReadObject(File envHome, Object object) throws Exception
//package com.java2s; /*-/* w ww.j a v a 2 s . c o m*/ * * This file is part of Oracle Berkeley DB Java Edition * Copyright (C) 2002, 2015 Oracle and/or its affiliates. All rights reserved. * * Oracle Berkeley DB Java Edition is free software: you can redistribute it * and/or modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation, version 3. * * Oracle Berkeley DB Java Edition 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 Affero * General Public License for more details. * * You should have received a copy of the GNU Affero General Public License in * the LICENSE file along with Oracle Berkeley DB Java Edition. If not, see * <http://www.gnu.org/licenses/>. * * An active Oracle commercial licensing agreement for this product * supercedes this license. * * For more information please contact: * * Vice President Legal, Development * Oracle America, Inc. * 5OP-10 * 500 Oracle Parkway * Redwood Shores, CA 94065 * * or * * berkeleydb-info_us@oracle.com * * [This line intentionally left blank.] * [This line intentionally left blank.] * [This line intentionally left blank.] * [This line intentionally left blank.] * [This line intentionally left blank.] * [This line intentionally left blank.] * EOF * */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public class Main { public static Object serializeAndReadObject(File envHome, Object object) throws Exception { File output = new File(envHome, "configure.out"); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(output)); out.writeObject(object); out.close(); if (!output.exists()) { throw new IllegalStateException("Can't create the output for serialized object."); } ObjectInputStream in = new ObjectInputStream(new FileInputStream(output)); Object newObject = in.readObject(); in.close(); if (!output.delete()) { throw new IllegalStateException( "Can't delete the output for serialized object after " + "testing is done."); } return newObject; } }