Here you can find the source of deserialize(byte[] bytes, boolean zipped)
Parameter | Description |
---|---|
bytes | serialized representation of the object |
zipped | or not |
Parameter | Description |
---|---|
IOException | the iO exception |
ClassNotFoundException | the class not found exception |
public static Object deserialize(byte[] bytes, boolean zipped) throws IOException, ClassNotFoundException
//package com.java2s; /*//from w ww.ja v a 2 s . com * Copyright (c) 2005-2016 Vincent Vandenschrick. All rights reserved. * * This file is part of the Jspresso framework. * * Jspresso 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. * * Jspresso 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 Jspresso. If not, see <http://www.gnu.org/licenses/>. */ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.util.zip.GZIPInputStream; public class Main { /** * Deserialize a table of bytes to an Object instance. * * @param bytes serialized representation of the object * @param zipped or not * @return the Object created after * @throws IOException the iO exception * @throws ClassNotFoundException the class not found exception */ public static Object deserialize(byte[] bytes, boolean zipped) throws IOException, ClassNotFoundException { ByteArrayInputStream bi = new ByteArrayInputStream(bytes); ObjectInputStream oi; if (zipped) { oi = new ObjectInputStream(new GZIPInputStream(bi)); } else { oi = new ObjectInputStream(bi); } Object o = oi.readObject(); oi.close(); return o; } }