ObjectInputStream
has also methods like readFully(byte[] buf)
, so there is no need to use InputStream.
Then, if you open an ObjectInputStream on an InputStream, you may not use that InputStream any more, in order not to break functionality of ObjectInputStream.
APPENDED
ObjectInputStream is a subclass of InputStream, so you can call all methods of InputStream on an ObjectInputStream instance, but not simultaneously. So you have to develop a protocol which prescribes when connection is used as ObjectInputStream and when as InputStream. If one side sends message via InputStream interface and the other reads it from ObjectInputStream (or vice versa), an error is inevitable.