question: public static int readSingleByte ( InputStream in ) throws IOException { byte [ ] buffer = new byte [ 1 ] ; int result = in . read ( buffer , 0 , 1 ) ; return ( result != - 1 ) ? buffer [ 0 ] & 0xff : - 1 ; }
target:  Implements InputStream.read(int) in terms of InputStream.read(byte[], int, int). InputStream assumes that you implement InputStream.read(int) and provides default implementations of the others, but often the opposite is more efficient.