import sun.misc.*; import java.io.*; public class CRCCalculator { public static void main(String[] args) { CRC16 myCRC = new CRC16(); int b = 0; for (int i=0; i < args.length; i++) { // int len = 0; try { FileInputStream fis = new FileInputStream(args[i]); while ((b = fis.read()) != -1) { // System.err.println(len++ + ":" + (char) b); myCRC.update((byte) b); } System.out.println(args[i] + " CRC: " + myCRC.value); } catch (IOException e) { System.err.println("Error reading file " + args[i] + "\n" + e); } myCRC.reset(); } } }