import java.io.*; import java.io.IOException; import java.util.zip.*; import java.util.zip.CheckedOutputStream; public class CheckWriteDemo1 { public static void main(String args[]) { String newfile = "newtestfile.txt"; String oldfile = "oldtestfile.txt"; byte[] buffer = new byte[1024]; try { FileOutputStream fileoutStream = new FileOutputStream(newfile); CheckedOutputStream outstream = new CheckedOutputStream(fileoutStream,new CRC32()); FileInputStream inStream = new FileInputStream(oldfile); int length; while ((length = inStream.read(buffer)) > 0) { outstream.write(buffer, 0, length); } System.out.println("The value of CRC32 Checksum is : " + outstream.getChecksum().getValue()); System.out .println(" Content of one file successfully written in other file "); } catch (IOException ioe) { System.out.println("IOException : " + ioe.getMessage()); } } }