I am trying to convert audio file to the byte array, but it seems it is not getting converted correctly. I am recording sound using mic, then converting that file to byte array using file's path on the device.
The desired byte array should be like 0x12323
But it is coming like this string [B@14746f6
Below is the code to convert audio to byte array
file is the path of the file on the device. File type is amr
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream out = new ByteArrayOutputStream();
int read = 0;
byte[] buffer = new byte[1024];
while (read != -1) {
read = fis.read(buffer);
if (read != -1)
out.write(buffer,0,read);
}
out.close();
byte[] bytes = out.toByteArray();
Log.e("byte array" ,bytes.toString());
[B@14746f6is the default type of string returned bytoStringObject method. Is not the value (bytes) of the array.filebut i know thatbytes.toString()will not return you the single bytes saved in the array as a string.Log.e("byte array" , Arrays.toString(bytes));your code looks good, but as EasyJoin says, you are printing it incorrectly