views:

57

answers:

1

I have created an android app. It sends a data message on a port for communicating with the same app on some other phone. While sending the message, i have encoded it into binary data using ISO8859_1 encoding.

byte[] b1=payload.getbytes();

I am able to receive the data message at the receiving end. But the problem is that after receving it in binary format , My app needs to decode the message back to string or human read-able format. But i am not able to do the same.

I have tried to convert it into String using 'toString()' but string contains binary character .

pls help.

+1  A: 

Try this:

try {    
  String s = new String(b1, "ISO8859_1");
} catch (UnsupportedEncodingException e) {
// ...
}
Edi