How to create Avro data from InputsStream

Below snippet can be used to convert avro file read as InputStream to GenericRecord

/**
* Read Avro file from InputStream And add each record to an Arraylist. *
* @param is InputStream
* @retum List<GenericRecord>
*@throws IOException
*/
public static List < GenericRecord > convertIsToAvro(InputStream is) throws IOException {
DataFileStream < Object > reader = new DataFileStream < Object> (is, new GenericDatumReader < Object> ());
List < GenericRecord > recordList = new ArrayList < > ();
while (reader.hasNext()) {
recordList.add((GenericRecord) reader.next());
}
return recordList;
}