Here you can find the source of decode(byte[] bytes)
@SuppressWarnings("unchecked") public static final <T extends Serializable> T decode(byte[] bytes)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; public class Main { @SuppressWarnings("unchecked") public static final <T extends Serializable> T decode(byte[] bytes) { if (bytes == null) { return null; }/*w w w . j av a2 s. c om*/ T t = null; Exception thrown = null; try { ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bytes)); t = (T) oin.readObject(); } catch (IOException e) { e.printStackTrace(); thrown = e; } catch (ClassNotFoundException e) { e.printStackTrace(); thrown = e; } catch (ClassCastException e) { e.printStackTrace(); thrown = e; } finally { if (null != thrown) throw new RuntimeException("Error decoding byte[] data to instantiate java object - " + "data at key may not have been of this type or even an object", thrown); } return t; } }