code: private int nextByte() throws IOException {
          int result = 0;
          if (!endOfStream) {
              result = read();
              if (result == -1) {
                  endOfStream = true;
              }
          }
          return endOfStream ? 0 : result;
      }
docs: Reads the next byte.
  
  @return the next byte
  @throws IOException
  if an error occurs