The following code prints
[B@40545a60,[B@40545a60abc exp
But I want to print abc
, so that I can retrieve the correct message from the receiving system.
public class Operation {
InetAddress ip;
DatagramSocket dsock;
DatagramPacket pack1;
byte[] bin,bout;
WifyOperation(InetAddress Systemip)
{
ip=Systemip;
try {
dsock=new DatagramSocket();
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void sendbyte()
{
String senddata="abc";
bout=senddata.getBytes();
pack1=new DatagramPacket(bout,bout.length,ip,3322);
try {
dsock.send(pack1);
Log.d(pack1.getData().toString(),"abc exp");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
How can I retrieve string instead of byte from the packet pack1
?