Here you can find the source of deserialize(byte[] bytes, Class
public static <T> T deserialize(byte[] bytes, Class<T> clazz)
//package com.java2s; /*/*from w ww. j a v a 2 s . c o m*/ * Copyright 1999-2101 Alibaba.com. All rights reserved. * This software is the confidential and proprietary information of Alibaba.com ("Confidential Information"). * You shall not disclose such Confidential Information and shall use it only in accordance with the terms of * the license agreement you entered into with Alibaba.com. */ import java.io.*; public class Main { public static <T> T deserialize(byte[] bytes, Class<T> clazz) { ByteArrayInputStream bais = null; ObjectInputStream ois = null; try { bais = new ByteArrayInputStream(bytes); ois = new ObjectInputStream(bais); Object object = ois.readObject(); return clazz.cast(object); } catch (Exception e) { throw new RuntimeException(e); } finally { closeQuietly(bais); closeQuietly(ois); } } private static void closeQuietly(Closeable c) { if (c == null) return; try { c.close(); } catch (IOException e) { } } }