public static long readLong(InputStream in, final int fitInBytes) throws IOException {
    long tmpLong = 0;
    for (int i = 0; i < fitInBytes; ++i) {
      tmpLong |= (in.read() & 0xffL) << (8 * i);
    }
    return tmpLong;
  }
Read long which was written to fitInBytes bytes and increment position.
@param fitInBytes In how many bytes given long is stored.
@return The value of parsed long.
@throws IOException on stream error
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java