public static void main(String[] args) {
String ida = "";
String volta = "";
String hex = "81800001000100030000";
String wBuffer = "";
for (int i = 0; i < hex.length(); i = i + 2)
wBuffer = wBuffer
+ (char) Integer.parseInt(hex.substring(i, i + 2), 16);
byte[] sendData;
sendData = wBuffer.getBytes();
for (char ch : wBuffer.toCharArray())
volta += Integer.toHexString(ch) + " ";
System.out.print(volta + "\n");
DatagramPacket sendPacket = new DatagramPacket(sendData,
sendData.length);
sendPacket.setData(sendData);
String fa = new String(((byte[]) sendPacket.getData()));
volta = "";
for (char ch : fa.toCharArray())
volta += Integer.toHexString(ch) + " ";
System.out.print(volta);
}
Quando o pacote chega do outro lado tanto o 80 quanto o 81 são transformados em 3f.
Alguém saberia como consertar isso.