code: public static FileIndex read(InputStream stream) throws IOException {
          //Creating raw input stream
          DataInputStream raw = new DataInputStream(stream);
  
          //Reading magic number
          int magic = raw.readInt();
          if (magic != MAGIC)
              throw new IOException("Wrong magic number");
  
          //Reading length
          int length = raw.readInt();
  
          //Reading whole index
          byte[] buffer = new byte[length];
          raw.read(buffer);
  
          //Creating uncompressed stream
          InflaterInputStream inflater = new InflaterInputStream(new ByteArrayInputStream(buffer));
          DataInputStream dataStream = new DataInputStream(inflater);
  
          //Reading step
          long step = dataStream.readLong();
          long startingRecordNumner = dataStream.readLong();
          long lastRecordNumber = dataStream.readLong();
  
          //Reading meta record count
          int metaRecordsCount = dataStream.readInt();
  
          //Reading meta records
          Map<String, String> metadata = new HashMap<>();
          String key, value;
          while (--metaRecordsCount >= 0) {
              key = dataStream.readUTF();
              value = dataStream.readUTF();
              metadata.put(key, value);
          }
  
          //Reading entries number
          int size = dataStream.readInt();
  
          //Creating array for index
          TLongArrayList index = new TLongArrayList(size);
  
          //Reading index
          long last = 0, val;
          for (int i = 0; i < size; ++i) {
              val = IOUtil.readRawVarint64(dataStream, -1);
              if (val == -1)
                  throw new IOException("Wrong file format");
              last += val;
              index.add(last);
          }
  
          return new FileIndex(step, metadata, index, startingRecordNumner, lastRecordNumber);
      }
docs: Reads index from input stream.
  
  @param stream input stream
  @return {@code FileIndex}
  @throws IOException