question: private byte readByteProtected ( DataInputStream istream ) throws java . io . IOException { byte [ ] rcvBuffer = new byte [ 1 ] ; while ( true ) { int nchars ; nchars = istream . read ( rcvBuffer , 0 , 1 ) ; if ( nchars > 0 ) { return rcvBuffer [ 0 ] ; } } }
target:  Read a single byte, protecting against various timeouts, etc. <P> When a gnu.io port is set to have a receive timeout (via the enableReceiveTimeout() method), some will return zero bytes or an EOFException at the end of the timeout. In that case, the read should be repeated to get the next real character.