Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert Byte array to unsigned int ?

HurukanNov 24 2010 — edited Nov 24 2010
Greetings,

I've no particular knowledge in Java programming and I've an issue with a conversion.

The exception thrown is "Number Format Exception For input string: "249" when I execute the following code:

readbytes=SocketInput.read(bMessage);
NetMessage=new String(bMessage);
NetMessage=NetMessage.substring(0,readbytes);

if(NetMessage.equals("NORES"))
NetMessage="0";

int res=0;
try
{
res=Byte.valueOf(NetMessage);
}
catch(NumberFormatException nfe)
{
AddMessage("Number Format Exception "+nfe.getMessage()+"["+bMessage.toString()+"]");
}
This post has been answered by 800330 on Nov 24 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2010
Added on Nov 24 2010
4 comments
1,194 views