@@ -0,0 +1,981 @@
+package org.finikes.sider.utils;%0A%0A/**%0A * %0A * @author Finikes.Wu%0A *%0A */%0Apublic class CRC16 %7B%0A%09private short%5B%5D crcTable = new short%5B256%5D;%0A%09private static final int POLY = 0x1021;%0A%0A%09private static final CRC16 INSTANCE = new CRC16();%0A%0A%09public static final CRC16 getInstance() %7B%0A%09%09return INSTANCE;%0A%09%7D%0A%0A%09private CRC16() %7B%0A%09%09computeCrcTable();%0A%09%7D%0A%0A%09private short getCrcOfByte(int aByte) %7B%0A%09%09int value = aByte %3C%3C 8;%0A%0A%09%09for (int count = 7; count %3E= 0; count--) %7B%0A%09%09%09if ((value & 0x8000) != 0) %7B%0A%09%09%09%09value = (value %3C%3C 1) %5E POLY;%0A%09%09%09%7D else %7B%0A%09%09%09%09value = value %3C%3C 1;%0A%09%09%09%7D%0A%0A%09%09%7D%0A%09%09value = value & 0xFFFF;%0A%09%09return (short) value;%0A%09%7D%0A%0A%09private void computeCrcTable() %7B%0A%09%09for (int i = 0; i %3C 256; i++) %7B%0A%09%09%09crcTable%5Bi%5D = getCrcOfByte(i);%0A%09%09%7D%0A%09%7D%0A%0A%09public short getCrc(byte%5B%5D data) %7B%0A%09%09int crc = 0;%0A%09%09int length = data.length;%0A%09%09for (int i = 0; i %3C length; i++) %7B%0A%09%09%09crc = ((crc & 0xFF) %3C%3C 8) %5E crcTable%5B(((crc & 0xFF00) %3E%3E 8) %5E data%5Bi%5D) & 0xFF%5D;%0A%09%09%7D%0A%09%09crc = crc & 0xFFFF;%0A%09%09return (short) crc;%0A%09%7D%0A%7D%0A

Create CRC16.java