ObjectInputStream.readObject()可以返回null吗? [英] Could ObjectInputStream.readObject() return null?

查看:346
本文介绍了ObjectInputStream.readObject()可以返回null吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ObjectInputStream.readObject()方法可以返回null吗?

Could ObjectInputStream.readObject() method return null?

推荐答案

是。

您可以将 null 序列化为 writeObject(),因此您可以从 readObject()

You can serialize null by passing it to writeObject(), therefore you can get it back from readObject().

但是,如果你问的是错误的情况,答案是否定的,因为在错误的情况下 readObject()抛出异常。

However, if you are asking about the case of error, the answer is no, since in the case of error readObject() throws an exception.

这篇关于ObjectInputStream.readObject()可以返回null吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆