Here you can find the source of deserialize(byte[] data)
public static <T extends Serializable> T deserialize(byte[] data)
//package com.java2s; /*/* w w w . jav a2 s .c o m*/ * This file is part of Bitsquare. * * Bitsquare 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, either version 3 of the License, or (at * your option) any later version. * * Bitsquare 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 * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. */ import java.io.*; public class Main { public static <T extends Serializable> T deserialize(byte[] data) { ByteArrayInputStream bis = new ByteArrayInputStream(data); ObjectInput in = null; Object result = null; try { in = new ObjectInputStream(bis); result = in.readObject(); if (!(result instanceof Serializable)) throw new RuntimeException("Object not of type Serializable"); } catch (Exception e) { e.printStackTrace(); } finally { try { bis.close(); } catch (IOException ex) { // ignore close exception } try { if (in != null) { in.close(); } } catch (IOException ex) { // ignore close exception } } return (T) result; } }