void read ( BlockId blk , IoBuffer buffer ) { try { IoChannel fileChannel = getFileChannel ( blk . fileName ( ) ) ; // clear the buffer buffer . clear ( ) ; // read a block from file fileChannel . read ( buffer , blk . number ( ) * BLOCK_SIZE ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw new RuntimeException ( "cannot read block " + blk ) ; } }
Reads the contents of a disk block into a byte buffer .