What would happen if I invoke the readObject function on an ObjectInputStream that doesn't contain data?
Will it throw an I/O exception?
I'm trying to read and write data across threads using PipedInputStream wrapped with ObjectInputStream and ObjectOutputStream.
I tried it out, the readObject was blocking the thread till data was added into the stream, but if I close the stream during this blocked state, it would throw an EOFException
When you call readObject() on a DataInputStream, it will block until there is data available to read. If you close the stream while it is blocked, it will throw an EOFException. This is because the DataInputStream will try to read data from the stream, but the stream will be closed and there will be no data to read.