Here you can find the source of serializeAndReturnDeserializedObject( T object)
public static <T extends Serializable> T serializeAndReturnDeserializedObject( T object) throws IOException, ClassNotFoundException
//package com.java2s; /*/*from w w w . ja v a2 s . c om*/ * Copyright (C) 2011 akquinet tech@spree GmbH * * This file is part of the Cuckoo Resource Adapter for SAP. * * Cuckoo Resource Adapter for SAP 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 3 of the License, or (at your * option) any later version. * * Cuckoo Resource Adapter for SAP 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 Cuckoo Resource Adapter for SAP. If not, see <http://www.gnu.org/licenses/>. */ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { public static <T extends Serializable> T serializeAndReturnDeserializedObject( T object) throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(object); out.close(); ByteArrayInputStream bain = new ByteArrayInputStream( baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bain); @SuppressWarnings({ "unchecked" }) T managerRead = (T) in.readObject(); in.close(); return managerRead; } }