首页>代码>effective_java书籍配套源码>/effective_java配套源码/examples/Chapter10/Item56/BogusPeriod.java
// Page 225

import java.io.*;

public class BogusPeriod {
    // Byte stream could not have come from real Period instance
    private static final byte[] serializedForm = new byte[] {
    (byte)0xac, (byte)0xed, 0x00, 0x05, 0x73, 0x72, 0x00, 0x06,
    0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x40, 0x7e, (byte)0xf8,
    0x2b, 0x4f, 0x46, (byte)0xc0, (byte)0xf4, 0x02, 0x00, 0x02,
    0x4c, 0x00, 0x03, 0x65, 0x6e, 0x64, 0x74, 0x00, 0x10, 0x4c,
    0x6a, 0x61, 0x76, 0x61, 0x2f, 0x75, 0x74, 0x69, 0x6c, 0x2f,
    0x44, 0x61, 0x74, 0x65, 0x3b, 0x4c, 0x00, 0x05, 0x73, 0x74,
    0x61, 0x72, 0x74, 0x71, 0x00, 0x7e, 0x00, 0x01, 0x78, 0x70,
    0x73, 0x72, 0x00, 0x0e, 0x6a, 0x61, 0x76, 0x61, 0x2e, 0x75,
    0x74, 0x69, 0x6c, 0x2e, 0x44, 0x61, 0x74, 0x65, 0x68, 0x6a,
    (byte)0x81, 0x01, 0x4b, 0x59, 0x74, 0x19, 0x03, 0x00, 0x00,
    0x78, 0x70, 0x77, 0x08, 0x00, 0x00, 0x00, 0x66, (byte)0xdf,
    0x6e, 0x1e, 0x00, 0x78, 0x73, 0x71, 0x00, 0x7e, 0x00, 0x03,
    0x77, 0x08, 0x00, 0x00, 0x00, (byte)0xd5, 0x17, 0x69, 0x22,
    0x00, 0x78 };

    public static void main(String[] args) {
        Period p = (Period) deserialize(serializedForm);
        System.out.println(p);
    }

    // Returns the object with the specified serialized form
    public static Object deserialize(byte[] sf) {
        try {
            InputStream is = new ByteArrayInputStream(sf);
            ObjectInputStream ois = new ObjectInputStream(is);
            return ois.readObject();
        } catch (Exception e) {
            throw new IllegalArgumentException(e.toString());
        }
    }
}
最近下载更多
湮灭圣者  LV1 1月20日
大隐隐于市  LV2 2021年7月2日
有理想的中年人  LV1 2021年3月16日
水木山  LV1 2021年3月10日
sddyzm  LV7 2020年9月4日
ttxng1  LV1 2020年5月28日
尔丫垚  LV1 2020年5月25日
wsk588  LV26 2020年1月15日
wwslu1317  LV1 2019年12月23日
hepingzhe114  LV1 2019年9月25日
最近浏览更多
湮灭圣者  LV1 1月20日
15575564465  LV1 2023年9月14日
朱俪的邮件及存储  LV8 2023年3月22日
绝对零度  LV2 2022年8月2日
你脚上银铃响了  LV1 2021年10月27日
大隐隐于市  LV2 2021年7月2日
916403064  LV2 2021年6月13日
smile soft 2021年4月28日
暂无贡献等级
有理想的中年人  LV1 2021年3月16日
水木山  LV1 2021年3月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友