how to retrive String from DatagramPacket
- by sajith
the following code prints
[B@40545a60,[B@40545a60abc exp
but i want to print abc,so that i can retrive 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"+"123";
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 i retrieve string instead of byte from the packet pack1