cmathz123 2008-11-11 22:30
浏览 626
已采纳

大家帮我找一下问题所在???Syntax error, insert ";" to complete

package com.jsp.javabean;

import java.io.IOException;

public class CRC16Checker {
private static int[] index = new int[] { 16, 15, 2, 0 };
private static int[] getBinary(String text)
{
StringBuffer num = new StringBuffer();
String s;
char ch;
for (int i = 0; i < text.length(); i++)

    { // Change each char to
        s = Integer.toBinaryString(text.charAt(i));                                     // binary code.


        for (int j = 8 - s.length(); j > 0; j--) 
            num.append(0);
        num.append(s);
    }
    int len = num.length();
    int[] code = new int[len];
    for (int i = 0; i < len; i++) // Change each 0/1 char to int.
        code[i] = Character.getNumericValue(num.charAt(i));
    return code;

   }

private static String toHex(int[] num) 
{
    StringBuffer hex = new StringBuffer(num.length / 4);
    char[] ch = new char[4];
    for (int i = 0; i < num.length;) 
    {

        ch[0] = Character.forDigit(num[i++], 2);
        ch[1] = Character.forDigit(num[i++], 2);
        ch[2] = Character.forDigit(num[i++], 2);
        ch[3] = Character.forDigit(num[i++], 2);

        hex.append(Integer.toHexString(Integer.parseInt(String.valueOf(ch), 2)));
    }
    return hex.toString();

  }

// CRC codes main process
public static int[] makeCRCCodes(int[] sourceCodes, int[] multinomial) {

    // CRC码数组总长为原码长加上校验码码长。数组前部存放原码。校验码存放在数组
    // 最后的N位。校验码长度决定于生成多项式数组0位置上的元素。
        int sourceLength = sourceCodes.length;
        int codesLength = sourceLength + multinomial[0];
        int[] crcCodes = new int[codesLength];
        // 拷贝原码。
        System.arraycopy(sourceCodes, 0, crcCodes, 0, sourceLength);
        int temp, pos;
        // 除法器。
        for (int i = 0; i < sourceLength; i++) {

            // 用第i位原码和第一个寄存器值模二加。
            temp = (crcCodes[sourceLength] + sourceCodes[i]) % 2;// /没有用crcCodes[sourceLength]
                                                    // = 0

            // 第二个寄存器及以后的所有寄存器值前移1位。
            System.arraycopy(crcCodes, sourceLength + 1, crcCodes, sourceLength, multinomial[0] - 1);

            // 最后一个寄存器值存放计算好的输入值。
            crcCodes[codesLength - 1] = temp;
            // 按生成多项式的值算出位置,模二加出该寄存器的值。
            for (int j = index.length - 2; j > 0; j--) {
                pos = codesLength - multinomial[j] - 1;
                crcCodes[pos] = (crcCodes[pos] + temp) % 2;
            }
        }
        return crcCodes;

     }

public static void main(String[] args) throws IOException {
    System.out.print("Input hex data :");
    StringBuffer buf = new StringBuffer();
    char ch = (char) System.in.read();
    while (ch != '\n' /*&& ch != ''*/) {
        buf.append(ch);
        ch = (char) System.in.read();
    }

    int[] b = CRC16Checker.getBinary(buf.toString());

    b = CRC16Checker.makeCRCCodes(b, CRC16Checker.index);

    for (int i = 0; i < b.length;) {
        for (int j = 0; j < 4; j++, i++) System.out.print(b[i]);
        System.out.print(' ');
    }
    System.out.println();

    System.out.println("The CRC16 code is :" + CRC16Checker.toHex(b));

    }
}

Severity and Description Path Resource Location Creation Time Id
Syntax error, insert ";" to complete ReturnStatement Test/src/com/jsp/javabean CRC16Checker.java line 26 1226413351765 846
Severity and Description Path Resource Location Creation Time Id
Syntax error, insert ";" to complete ReturnStatement Test/src/com/jsp/javabean CRC16Checker.java line 43 1226413351765 847
Severity and Description Path Resource Location Creation Time Id
Syntax error, insert ";" to complete ReturnStatement Test/src/com/jsp/javabean CRC16Checker.java line 75 1226413351765 848
Severity and Description Path Resource Location Creation Time Id
Syntax error, insert ";" to complete Statement Test/src/com/jsp/javabean CRC16Checker.java line 97 1226413351765 849

  • 写回答

3条回答 默认 最新

  • soartju 2008-11-11 22:36
    关注

    没发现有问题,格式化一下,吧多余的空字符串去了就没有问题了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?