public byte [ ] read ( long record ) throws IOException { // (+ recordSize) allows skipping metadata record long pos = record * recordSize + recordSize ; if ( pos >= size ) { final String fmt = "bad seek to position: %d (size is %d)" ; final String msg = format ( fmt , pos , size ) ; throw new InvalidArgument ( msg ) ; } raf . seek ( pos ) ; byte [ ] ret = new byte [ recordSize ] ; int read = raf . read ( ret ) ; if ( read != recordSize ) { final String fmt = "read %d bytes, but expected %d" ; final String msg = format ( fmt , read , recordSize ) ; throw new InvalidArgument ( msg ) ; } return ret ; }
Reads a record from this record file .