Here you can find the source of deserialize(Class
@Nullable public static <T> T deserialize(Class<T> type, @Nullable byte[] objectBytes)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.io.BaseEncoding.base16; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import javax.annotation.Nullable; public class Main { /**/*from w w w. j a v a2 s.com*/ * Turns a byte array into an object. * * @return deserialized object or {@code null} if {@code objectBytes} is {@code null} */ @Nullable public static <T> T deserialize(Class<T> type, @Nullable byte[] objectBytes) { checkNotNull(type); if (objectBytes == null) { return null; } try { return type.cast(new ObjectInputStream(new ByteArrayInputStream(objectBytes)).readObject()); } catch (ClassNotFoundException | IOException e) { throw new IllegalArgumentException("Unable to deserialize: objectBytes=" + base16().encode(objectBytes), e); } } }