Here you can find the source of deserialize(final byte[] inBytes)
Parameter | Description |
---|---|
T | the type parameter |
inBytes | The bytes to be deserialized |
public static <T> T deserialize(final byte[] inBytes)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; public class Main { /**/*from w w w .j av a 2s . co m*/ * Deserialize an object. * @param <T> the type parameter * @param inBytes The bytes to be deserialized * @return the object * @since 5.0.0 */ public static <T> T deserialize(final byte[] inBytes) { final ByteArrayInputStream inputStream = new ByteArrayInputStream(inBytes); return deserialize(inputStream); } /** * Deserialize an object. * @param <T> the type parameter * @param inputStream The stream to be deserialized * @return the object * @since 5.0.0 */ public static <T> T deserialize(final InputStream inputStream) { ObjectInputStream in = null; try { in = new ObjectInputStream(inputStream); final T obj = (T) in.readObject(); return obj; } catch (final ClassNotFoundException | IOException e) { throw new RuntimeException(e); } finally { if (in != null) { try { in.close(); } catch (final IOException e) { throw new RuntimeException(e); } } } } }