将audio.amr写入字节数组

时间:2017-03-14 08:35:18

标签: java

我的Android应用程序存在问题。我需要将现有的音频文件转换为字节数组。我的音频文件位于/sdcard/SomeFolder/111.amr

    try {
        convert();
    }catch (IOException e){
        RLog.log(LogLevel.HIGH, "MyApp", "Audio File not found");
    }

转换方法看起来像这样

public void convert() throws IOException {
    FileInputStream fis = new FileInputStream (Environment.getExternalStorageDirectory().getPath()+ "SomeFolder/111.amr");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] b = new byte[2048];

    for (int readNum; (readNum = fis.read(b)) != -1;) {
        bos.write(b, 0, readNum);
    }
    byte[] bytes = bos.toByteArray();

    FileOutputStream fos = new FileOutputStream(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/recording.pcm");
    fos.write(bytes);
    fos.close();
}

但是,当我尝试使用方法convert()时,我会FileNotFoundExeption - "Audio File not found"

你能帮我吗?路径有什么问题?

0 个答案:

没有答案