Bytes of recorded audio was sent together with HTTP request body. When the request is received on the server side, the audio data looks like this:
\u0000\u0000\u0000\u0000\u0000\u0000��\u0002\u0000������4\u0000M\u0000@\u0000%\u0000\u0014\u0000����������\u0015\u0000M\u0000r\u0000�\u0000_\u0000C\u0000^\u0000V\u0000\u0007\u0000��\"\u0000;\u0000>\u0000\u0005\u0000����������������\f\u0000+\u0000K\u0000e\u0000.\u0000������������\u0003\u0000\b\u0000����������\"\u0000G\u0000V\u0000(\u0000 \u0000\u0004\u0000����������\u0003\u0000W\u0000�\u0000Z\u0000a\u0000{\u0000,\u0000��������\u001E\u0000��������1\u0000\u001A\u0000\u0011\u0000(\u0000/\u0000\u0016\u0000��������0\u0000/\u00002\u0000;\u0000������d�������\u001F\u00009\u00006\u0000j\u0000[\u0000'\u0000������������\u000E\u00009\u0000%\u0000����\u0015\u0000(\u00003\u0000+\u0000'\u0000������<\u0000F\u0000=\u0000h\u0000�\u0000M\u0000��������������T\u0000i\u0000]
How can I convert this string back to the original audio data bytes?
I tried calling getBytes() but it doesn't seem right.
----- EDIT -----
Posting the code for HTTP Request would be too long. I'll cite a short sample here.
public static void main(String args[]) throws Exception
{
byte[] test = new byte[]{(byte)0xfc, (byte)0xff, (byte)0xff, (byte)0xff};
String testString = new String(test);
System.out.println(testString);
System.out.println(getHexString(testString.getBytes()));
}
public static String getHexString(byte[] bytes)
{
char[] hexArray = "0123456789ABCDEF".toCharArray();
char[] hexChars = new char[bytes.length * 2];
for ( int j = 0; j < bytes.length; j++ )
{
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
The code above gives the following result
����
EFBFBDEFBFBDEFBFBDEFBFBD
When I convert bytes FC, FF, FF, FF to string, I get ����. When I convert the string back to bytes I get EF BF BD EF BF BD EF BF BD EF BF BD. I want to get the original bytes FC, FF, FF, FF from ����.