import java.util.zip.CheckedInputStream; import java.util.zip.CRC32; import java.io.*; public class ChecksumByteArrayCRC{ public static void main(String[] args){ try{ String string = new String("A" + "\u00ea" + "\u00f1" + "\u00fc" + "C"); System.out.println("The data size is " + string.length()); byte buffer[] = string.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(buffer); CheckedInputStream cis = new CheckedInputStream(bais, new CRC32()); byte readBuffer[] = new byte[5]; while (cis.read(readBuffer) >= 0){ long value = cis.getChecksum().getValue(); System.out.println("The value of checksum is " + value); } } catch(Exception e){ System.out.println("Exception has been caught" + e); } } }