Hi
i have the following code. compiled no error. but in runtime it give me error message :
Error Message:
Code:
I used System.out.prin tln to debug, "tested ab" printed but "called" IS NOT printed, so i guess the null pointer is came from short sh = ..........
Why nullpointer?
I dont see which one is null pointer.
anyone help ?
thanks.
i have the following code. compiled no error. but in runtime it give me error message :
Error Message:
Code:
java.lang.NullPointerException at com.sun.midp.ssl.MD5.doFinal(+4) at AESEncrypter.genHash(+55) at MEMerchantInterface$HelpSelector.commandAction(+734) at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282) at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10) at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68) at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47) at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250)
Code:
public static String genHash(String s)
throws java.security.NoSuchAlgorithmException {
byte[] ab = null;
try {
com.sun.midp.ssl.MessageDigest md = com.sun.midp.ssl.MessageDigest.getInstance(com.sun.midp.ssl.MessageDigest.ALG_MD5, true);
md.update(s.getBytes(), 0, s.length()) ;
System.out.println("test1");
System.out.println("tested ab");
short sh = md.doFinal(s.getBytes(), 0, s.length(), ab, 0 );
System.out.println("called");
} catch (CryptoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return toHexString(ab) ;
}
Why nullpointer?
I dont see which one is null pointer.
anyone help ?
thanks.
Comment