import java.io.*; import java.util.zip.*; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.zip.CheckedOutputStream; import java.io.IOException; class CheckedWrite { public static void main(String args[]) { try { FileOutputStream fout = new FileOutputStream("testfile1.txt"); Adler32 adler = new Adler32(); CheckedOutputStream checkout = new CheckedOutputStream(fout, adler); FileInputStream fin = new FileInputStream("testfile.txt"); int length; for (int c = fin.read(); c != -1; c = fin.read()) { checkout.write(c); } System.out .println("content of a file successfully written in another file using Write(int b) method."); long value = checkout.getChecksum().getValue(); System.out.println("The Adler32 Checksum value : " + value); } catch (IOException e) { System.out.println("IOException : " + e.getMessage()); } } }