private HBaseProtos.RotateFileData read(Path path) throws IOException {
    byte[] data;
    int expectedChecksum;
    try (FSDataInputStream in = fs.open(path)) {
      int length = in.readInt();
      if (length <= 0 || length > maxFileSize) {
        throw new IOException("Invalid file length " + length
          + ", either less than 0 or greater then max allowed size " + maxFileSize);
      }
      data = new byte[length];
      in.readFully(data);
      expectedChecksum = in.readInt();
    }
    CRC32 crc32 = new CRC32();
    crc32.update(data);
    int calculatedChecksum = (int) crc32.getValue();
    if (expectedChecksum != calculatedChecksum) {
      throw new IOException(
        "Checksum mismatch, expected " + expectedChecksum + ", actual " + calculatedChecksum);
    }
    return HBaseProtos.RotateFileData.parseFrom(data);
  }
Constructs a new RotateFile object with the given parameters.
@param fs          the file system to use.
@param dir         the directory where the files will be created.
@param name        the base name for the files.
@param maxFileSize the maximum size of each file.
hbase-client/src/main/java/org/apache/hadoop/hbase/util/RotateFile.java