public boolean checkError(){
  try {
    out.flush();
  }
 catch (  IOException e) {
    hadError=true;
  }
  return hadError;
}

public boolean checkError ( ) { try { out . flush ( ) ; } catch ( IOException e ) { hadError = true ; } return hadError ; }
flush the stream and check its error state .
