Java Object Deserialize deserializeObject(byte[] serializedObj)

Here you can find the source of deserializeObject(byte[] serializedObj)

Description

Deserializes Object from byte array.

License

Open Source License

Exception

Parameter Description
IOException an exception
StreamCorruptedException an exception
ClassNotFoundException an exception

Declaration

public static Object deserializeObject(byte[] serializedObj)
        throws StreamCorruptedException, IOException, ClassNotFoundException 

Method Source Code

//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();
    }
}

Related

  1. deserializeObject(byte[] data)
  2. deSerializeObject(byte[] data)
  3. deserializeObject(byte[] data)
  4. deserializeObject(byte[] data, Class clazz)
  5. deserializeObject(byte[] obj)
  6. deserializeObject(File file)
  7. deserializeObject(File inFile)
  8. deserializeObject(final byte[] b)
  9. deserializeObject(final byte[] bytes)