本文介绍了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吗?
发布评论