Here you can find the source of deserializeFromByteArray(byte[] in)
Parameter | Description |
---|---|
in | byte[] source |
public static Object deserializeFromByteArray(byte[] in)
//package com.java2s; /* IoUtils/*ww w . j a va 2 s . c om*/ * * Created on Dec 8, 2004 * * Copyright (C) 2004 Internet Archive. * * This file is part of the Heritrix web crawler (crawler.archive.org). * * Heritrix is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * any later version. * * Heritrix 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 Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with Heritrix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; public class Main { /** * Utility method to deserialize Object from byte[]. * * @param in byte[] source * @return Object deserialized */ public static Object deserializeFromByteArray(byte[] in) { Object object; try { ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(in)); try { object = ois.readObject(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block throw new RuntimeException(e); } ois.close(); } catch (IOException e) { // shouldn't be possible throw new RuntimeException(e); } return object; } }