public synchronized void finishWriting(){
  doneWriting=true;
  notifyAll();
}

public synchronized void finishWriting ( ) { doneWriting = true ; notifyAll ( ) ; }
stream will close after the already written bytes are read .
