title: Avro schema parsing from data file
body: <p>Since the data file in avro embedded with the schema for that, the reader does not want to keep separate .avsc file to specify the schema.  I was searching for a java example that works in that way, I couldn't find that. Somebody, please help me to get a code sample for the same.</p>
  
  <pre><code>Schema schema = new Schema.Parser().parse(new File("./AvroSchema/emp.avsc"));
  
  DatumReader&lt;GenericRecord&gt; datumReader = new GenericDatumReader&lt;GenericRecord&gt;(schema);
  DataFileReader&lt;GenericRecord&gt; dataFileReader = new DataFileReader&lt;GenericRecord&gt;(new File("./AvroFileStore/empData.txt"), datumReader);
  
  GenericRecord emp = null;
  while (dataFileReader.hasNext()) {
      emp = dataFileReader.next(emp);
      System.out.println(emp);
  }
  </code></pre>
  
  <p>In this example we are providing the avro schema separately to <code>DataFileReader</code> by using <code>datumReader</code>. </p>