你遇到这种问题的时候,应该直接去找该公司的api提供技术人员

解决方案 »

  1.   

    String SPName = "softwife", SPPassword="softwife", SPType="sp";
    byte pData[] = new byte[1024]; int iCount = 0 , i;
    int iCommandID = 0x1; byte command[] = new byte[4];
    command[0] = (byte)( (iCommandID & 0xff000000) >>> 24);
    command[1] = (byte)( (iCommandID & 0x00ff0000) >>> 16);
    command[2] = (byte)( (iCommandID & 0x0000ff00) >>> 8);
    command[3] = (byte)( (iCommandID & 0x000000ff) ); byte name[] = SPName.getBytes();
    int nameLen = SPName.length() + 1 ;
    byte password[] = SPPassword.getBytes();

    int passwordLen = SPPassword.length() + 1;
    byte type[] = SPType.getBytes();
    int typeLen = SPType.length() + 1;
    iCount = 4*2 + nameLen + passwordLen + typeLen;
    byte len[] = new byte[4];
    len[0] = (byte)( (iCount & 0xff000000) >>> 24);
    len[1] = (byte)( (iCount & 0x00ff0000) >>> 16);
    len[2] = (byte)( (iCount & 0x0000ff00) >>> 8);
    len[3] = (byte)( (iCount & 0x000000ff) ); //数据的长度
    for(i=0; i<4; i++){
    pData[i] = len[i];
    }
    //指令代码
    for(i=0; i<4; i++){
    pData[i+4] = command[i];
    }
    //账号
    for(i=0; i<nameLen-1; i++){
    pData[i+8] = name[i];
    }
    pData[8+nameLen-1] = 0;
    //密码
    for(i=0; i<passwordLen-1; i++){
    pData[i+8+nameLen] = password[i];
    }
    pData[8+nameLen+passwordLen-1] = 0;
    //类型
    for(i=0; i<typeLen-1; i++){
    pData[i+8+nameLen+passwordLen] = type[i];
    }
    pData[8+nameLen+passwordLen+typeLen-1] = 0; System.out.println("4444");
    connection.send(pData);
    System.out.println("5555");
    ================================================================
    其中 connection.send(pData); 
    public void send(byte s[]) {
        writeThread.send(s);
    }
    ??? 为什么 提示
    java.lang.NullPointerException
         at com.softwife.sms.SMSManager.login(SMSManager.java:115)郁闷ing...
      

  2.   

    上面问题解决但又有新问题怎么将 byte[4] 转换成 int下面错在那里
    int iCommandID;
     
    iCommandID = (command[0].intValue()) & ((command[1].intValue())<<<8) & ((command[2].intValue())<<<16) & ((command[3].intValue())<<<24) ; 
      

  3.   

    iCommandID = (command[0].intValue()) & ((command[1].intValue())<<<8) & ((command[2].intValue())<<<16) & ((command[3].intValue())<<<24) ; 想实现什么功能
    如果
    command[0].intValue()没错,那你自己考虑自己写程序的问题了