File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes EOFException is null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "EOFException is null" Watch "EOFException is null" New topic

EOFException is null

Don Ho

Joined: Mar 07, 2012
Posts: 9

Hi all,

I have an app that acts as a server, and a java program, that connects to it via a TCP socket. The app then waits for commands from the client by calling DataInputStream.readInt(). If I then shut down the client application (when the socket connection is established, and the server is blocking at readInt()), a EOFException is thrown. If I catch it with a IOException Handler though, the Exception object is null! If I catch it with a EOFException Handler, it is a normal EOFException...

It works well, when I just use the EOFException Handler, I'm just curious, is this a bug, or a logical behaviour? I didn't know that Exception objects can be null... In a Stackoverflow question ( somebody had a similar problem, and one answer was that "Eclipse probably can't get a correct instance of this exception", but I do not understand what that means, could somebody explain?

I agree. Here's the link:
subject: EOFException is null
It's not a secret anymore!