public void testDeserialize() throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); BigInteger bi = new BigInteger("0"); oos.writeObject(bi); byte[] str = baos.toByteArray(); ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new ByteArrayInputStream(str))); Object obj = ois.readObject(); assertNotNull(obj); assertEquals(obj.getClass().getName(),"java.math.BigInteger"); assertEquals(((BigInteger)obj).intValue(), 0); }
关键处理
byte[] str = baos.toByteArray();
![php中文网最新课程二维码](/static/images/article_wechat2021.jpg?1111)
声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
- 上一篇:java RSA 生成公钥私钥
- 下一篇:JAVA软件配置—环境变量
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论