Java I/O

Checksumming

FileOutputputStream os =  new FileOutputStream("Temp1.tmp");

//CDC32 extends Checksum.
CRC32 crc32 = new CRC32();
CheckedOutputStream cos =  new CheckedOutputStream(os, crc32);
cos.write(1);
cos.write(2);

//Get the checksum for this file
long crc = crc32.getValue();

//Write this checksum to the stream.
cos.write(crc);

José M. Vidal .

9 of 13