Here you can find the source of deserialize(byte[] objectData)
Parameter | Description |
---|---|
objectData | The serialized object. |
null
on failure.
public static Object deserialize(byte[] objectData)
//package com.java2s; /*//from w ww . ja va 2 s . c om * Copyright (c) 2007-2016 AREasy Runtime * * This library, AREasy Runtime and API for BMC Remedy AR System, is free software ("Licensed 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 2.1 of the License, * or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ import java.io.*; public class Main { /** * Deserializes a single object from an array of bytes. * * @param objectData The serialized object. * @return The deserialized object, or <code>null</code> on failure. */ public static Object deserialize(byte[] objectData) { Object object = null; if (objectData != null) { // These streams are closed in finally. ObjectInputStream in = null; ByteArrayInputStream bin = new ByteArrayInputStream(objectData); BufferedInputStream bufin = new BufferedInputStream(bin); try { in = new ObjectInputStream(bufin); // If objectData has not been initialized, an exception will occur. object = in.readObject(); } catch (Exception e) { } finally { try { if (in != null) in.close(); if (bufin != null) bufin.close(); if (bin != null) bin.close(); } catch (IOException e) { } } } return object; } }