public static long decodeLong(InputStream stream) throws IOException {
  long result=0;
  int shift=0;
  int b;
  do {
    b=stream.read();
    if (b < 0) {
      if (shift == 0) {
        throw new EOFException();
      }
 else {
        throw new IOException("varint not terminated");
      }
    }
    long bits=b & 0x7F;
    if (shift >= 64 || (shift == 63 && bits > 1)) {
      throw new IOException("varint too long");
    }
    result|=bits << shift;
    shift+=7;
  }
 while ((b & 0x80) != 0);
  return result;
}

public static long decodeLong ( InputStream stream ) throws IOException { long result = 0 ; int shift = 0 ; int b ; do { b = stream . read ( ) ; if ( b < 0 ) { if ( shift == 0 ) { throw new EOFException ( ) ; } else { throw new IOException ( "varint not terminated" ) ; } } long bits = b & 0x7F ; if ( shift >= 64 || ( shift == 63 && bits > 1 ) ) { throw new IOException ( "varint too long" ) ; } result |= bits << shift ; shift += 7 ; } while ( ( b & 0x80 ) != 0 ) ; return result ; }
decodes a long value from the given stream .
