Skip to Main Content

Java Programming

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!

php Pack/unpack unsigned integer equivalent

800349Nov 3 2010 — edited Nov 3 2010
I'm trying to port some PHP code into Java which contains calls to Pack and Unpack which I'm trying to use which I'm having some problems with converting.
I realise Java doesn't have these functions but I've been fiddling around and looking around the net trying to get a solution. The php is using 'I' as its format mask which is Unsigned Integer so I've used :

Integer.toBinaryString(toStringInt)

which should be returning the unsigned integer but I'm having trouble trying to get it back from the binary string.

When I stick the result of the above code into Integer.parseInt(string, int) it gives me a number format exception

Can anyone help?
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2010
Added on Nov 3 2010
12 comments
746 views