I have a .wav
file in my disk drive. I need to convert that .wav
file to byte array
using java.
Can anyone help?
You can use Files.readAllBytes
to achieve this.
Read all the bytes from a file. The method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown.
For JRE < 1.7, regardless of extension
File file = new File(filePath);
InputStream fis = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
fis.read(buffer, 0, buffer.length);
fis.close();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With