code: public static int readRawVarint32(final InputStream is, int eofVaule) throws IOException {
          int result = 0;
          int shift = 0;
          for (; shift < 32; shift += 7) {
              final int b = is.read();
  
              if (b == -1)
                  if (shift == 0)
                      return eofVaule;
                  else
                      throw new IOException("Malformed Varint");
  
              result |= (b & 0x7f) << shift;
              if ((b & 0x80) == 0)
                  return result;
          }
          throw new IOException("Malformed Varint");
      }
docs: Read a raw Varint from the stream.
  
  <p>Based on com.google.protobuf.CodedInputStream class from Google's protobuf library.</p>