Avro format read with java library apache.avro

less than 1 minute read

  1. Import ‘org.apache.avro:avro:1.9.0’ (choose proper version)

  2. follow like this


    String path = getClass().getResource(path).getPath();
    File file = New File(path);

    DatumReader<GenericRecord> datumReader = new GenericDatumReader<>();
    DataFileReader<GenericRecord> dataFileReader = new DataFileReader<>(file, datumReader);
    record = dataFileReader.next(record);
    record.get(key).toString();