code: public static Schema getSchemaFromDataFile(Path dataFile, FileSystem fs) throws IOException {
      try (SeekableInput sin = new FsInput(dataFile, fs.getConf());
          DataFileReader<GenericRecord> reader = new DataFileReader<>(sin, new GenericDatumReader<GenericRecord>())) {
        return reader.getSchema();
      }
    }
docs: Get Avro schema from an Avro data file.