本文介绍了j2me中的java.lang.nullpointerexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个读取mifare卡的应用程序,但是当我通过APDU时,发生了在仿真器"java.lang.nullpointerexception"上的错误.在我像这样通过APDU之后,我已经成功检测到ISO14443_CARD >

I am writing an application for read the mifare card,but when I pass the APDU the error occur that on emulator "java.lang.nullpointerexception".I have successfully detect the ISO14443_CARD after that I pass the APDU like

if (tp.hasTargetType(TargetType.ISO14443_CARD)){
  form.append("Target is ISO14443_CARD\n");

 try {
            static byte[]   APDU_AUTH1 = { (byte) 0xff, (byte) 0x86, (byte) 0x00, (byte) 0x00, (byte) 0x05,(byte)0x01,(byte)0x00,(byte)0xfc,(byte)0x60,(byte)0x00};
            static byte[]   STATUS_BYTE = {(byte)0x90,(byte)0x00};
        if(STATUS_BYTE == iso14443.exchangeData(APDU_LOAD_KEY))
        {
         String value1 = new String("Hai!");
         textfield1.setString(value1);
         form.append(textfield1);

        }
        else
        {
            String value1 = new String("Hello!");
             textfield1.setString(value1);
             form.append(textfield1);
        }



     }
    catch (Exception ex) {
        form.append(ex.toString());
        }
 }

推荐答案

iso14443textfield1对象中的任何一个都可能为空.

Either of iso14443 or textfield1 objects is likely null.

使用调试方式(非常聪明的BTW,恭喜),您可以将检查记录如下:

With the way you debug things (quite smart BTW, my congratulations), you could log the checks about as follows:

form.append("\n\n iso14443 is null: [" + (iso14443 == null)
        + "],\n textfield1 is null: [" + (textfield1 == null) + "]");

这篇关于j2me中的java.lang.nullpointerexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 12:45