public List < ArchiveRecordHeader > validate ( int numRecords ) throws IOException { List < ArchiveRecordHeader > hdrList = new ArrayList < ArchiveRecordHeader > ( ) ; int recordCount = 0 ; setStrict ( true ) ; for ( Iterator < ArchiveRecord > i = iterator ( ) ; i . hasNext ( ) ; ) { recordCount ++ ; ArchiveRecord r = i . next ( ) ; if ( r . getHeader ( ) . getLength ( ) <= 0 && r . getHeader ( ) . getMimetype ( ) . equals ( MimetypeUtils . NO_TYPE_MIMETYPE ) ) { throw new IOException ( "record content is empty." ) ; } r . close ( ) ; hdrList . add ( r . getHeader ( ) ) ; } if ( numRecords != - 1 ) { if ( recordCount != numRecords ) { throw new IOException ( "Count of records, " + Integer . toString ( recordCount ) + " is not equal to expected " + Integer . toString ( numRecords ) ) ; } } return hdrList ; }
Validate the Archive file .