How can i check if the ObjectOutputStream has unread object wriiten to the stream? When i'm runnig my program which has server and client (the client sends the screen shot and the server displays it) in the client side i got an error(java.lang.OutOfMemoryError: Java heap space), any one can help me plz?

Normally you would have a separate thread waiting on a read from the input stream. When the server sends something, the read completes. The read is in a loop, so after receiving an object it just goes back to waiting for the next one.
However, if you want to poll the stream, the available() method returns the number of bytes waiting to be read.