@ Nullable public static Grib2Record findRecordByDrspos ( RandomAccessFile raf , long drsPos ) throws IOException { long pos = Math . max ( 0 , drsPos - ( 20 * 1000 ) ) ; // go back 20K Grib2RecordScanner scan = new Grib2RecordScanner ( raf , pos ) ; while ( scan . hasNext ( ) ) { ucar . nc2 . grib . grib2 . Grib2Record gr = scan . next ( ) ; Grib2SectionDataRepresentation drs = gr . getDataRepresentationSection ( ) ; if ( drsPos == drs . getStartingPosition ( ) ) return gr ; if ( raf . getFilePointer ( ) > drsPos ) break ; // missed it. } return null ; }
tricky bit of business . recapture the entire record based on drs position . for validation .