Directly after the bit of code you copied the text goes on to say:
Notice that DataStreams detects an end-of-file condition by catching EOFException, instead of testing for an invalid return value. All implementations of DataInput methods use EOFException instead of return values.
So, no, it's not Sun's fault that you didn't bother to read the explanation of the code.
And, before you go running off to use exceptions for flow control, know that doing such is considered to be poor programming, due to the relatively massive overhead of generating an exception verses simply testing conditions. Had they a choice in the case of DataInput, et al, they would not have done that way. (Feel free to contact Sun and suggest what return value could be used to indicate EOF when any value may be valid and expected)