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