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;
}

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 ; }
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 .
