convert between integer and string
The problem is like this:
Data transfer via socket. The sending side convert integer into string and the receiving side convert string back to integer. An exception appears when the receiving side wants to convert a text content into an integer. The exception is:
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:382)
at java.lang.Integer.parseInt(Integer.java:463)
The way I convert the integer into String (in an xml element creation method) is:
type.appendChild( document.createTextNode(new Integer(msg.type).toString()));
The way I convert the xml element String value back to integer is:
msgObj.type = Integer.parseInt(data.item(0).getNodeValue());//data.item(0).getNodeValue() returns a String value.
The run time exception occurs when doing the converting back to the integer. What could it be wrong?
Thanks.

