android studio 中有没有办法将音频文件转换为字节数组

Is there a way to convert audio files to byte array in android studio

我正在尝试将用户从他自己的音乐播放器中选择的音频文件存储到 sqlite 数据库中,我想知道有没有办法将音频文件转换为字节数组。

String path = ""; // Audio File path
InputStream inputStream = new FileInputStream(path); 
byte[] arr = readByte(inputStream);

Log.d("byte: ", "" + Arrays.toString(arr));

public static byte[] getBytesFromInputStream(InputStream is) throws IOException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    byte[] buffer = new byte[0xFFFF];
    for (int len = is.read(buffer); len != -1; len = is.read(buffer)) {
        os.write(buffer, 0, len);
    }

    return os.toByteArray();
}

try {
    String path = ""; // Audio File path
    InputStream inputStream = new FileInputStream(path);
    byte[] myByteArray = getBytesFromInputStream(inputStream);
    // ...
} catch(IOException e) {
    // Handle error...
}