Here you can find the source of deserializeObject(byte[] serializedObj)
Parameter | Description |
---|---|
IOException | an exception |
StreamCorruptedException | an exception |
ClassNotFoundException | an exception |
public static Object deserializeObject(byte[] serializedObj) throws StreamCorruptedException, IOException, ClassNotFoundException
//package com.java2s; /*************************************************************************** * Filename: Util.java/* www . jav a 2s. c o m*/ * Author: artjom.lind@ut.ee *************************************************************************** * Copyright (C) 2009 by Ulrich Norbisrath * devel@mail.ulno.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 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 Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *************************************************************************** * Description: * For handling the serialization and compression ***************************************************************************/ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.StreamCorruptedException; public class Main { /** * Deserializes Object from byte array. * @throws IOException * @throws StreamCorruptedException * @throws ClassNotFoundException */ public static Object deserializeObject(byte[] serializedObj) throws StreamCorruptedException, IOException, ClassNotFoundException { InputStream is = new ByteArrayInputStream(serializedObj); ObjectInput oi; oi = new ObjectInputStream(is); return oi.readObject(); } }