What is the correct way to convert my IP Packet data into a String?
问题 When I receive an IP Packet with my Android VpnService I read the headers first (as here), then I try to print the received data as follows: int lengthRemaining = packet.remaining(); if (lengthRemaining > 0) { byte[] data = new byte[lengthRemaining]; packet.get(data, packet.arrayOffset(), lengthRemaining); Log.d(TAG, "Packet-Data: " + new String(data, Charset.forName("UTF-8"))); } This results in out put like the following: Packet-Data: ����5��(��������������������www�google�com������ Or