> I am reading binary messages off of a port via UDP packets ->
> socket.receive(packet)
[quoted text clipped - 5 lines]
> the 1's and 0's to display instead of the asii characters? Any help is
> greatly appreciated!
Integer.toString(data, 2), for anything that fits in an int. Not that
if you're treating the byte as unsigned, you should instead do
Integer.toString(data & 0xff, 2) to correct for sign extension.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
fastman42 - 02 Dec 2005 19:24 GMT
The solution Integer.toString(int, int) does not work in my case. The
binary messages are being stored in the variable 'received' which is of
type byte[]. I want to be able to display the 1's and 0's of
'received' to the screen for human readability (not the ascii
characters). Sorry if i was not clear earlier.
Roedy Green - 02 Dec 2005 20:03 GMT
>The solution Integer.toString(int, int) does not work in my case. The
>binary messages are being stored in the variable 'received' which is of
>type byte[]. I want to be able to display the 1's and 0's of
>'received' to the screen for human readability (not the ascii
>characters). Sorry if i was not clear earlier.
use it once on each byte.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Chris Uppal - 02 Dec 2005 20:07 GMT
> The solution Integer.toString(int, int) does not work in my case. The
> binary messages are being stored in the variable 'received' which is of
> type byte[].
So use a loop ?
-- chris
>I want to output in binary format the variable received. How do I get
>the 1's and 0's to display instead of the asii characters? Any help is
>greatly appreciated!
see http://mindprod.com/jgloss/binary.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
fastman42 - 02 Dec 2005 20:11 GMT
Thanks for the help... I got it to work!