在这里,我有将音频流记录到文件的代码。问题是我想用正确的文件扩展名(主要是 .mp3 和 .aac)保存这个文件。我怎样才能做到这一点?
URLConnection conn = new URL(StringUrls[0]).openConnection();
InputStream in = conn.getInputStream();
BufferedOutputStream bufOutstream = new BufferedOutputStream(new FileOutputStream(new File(env.getExternalStorageDirectory()+"/temp.file")));
byte[] buffer = new byte[4096];
int len = in.read(buffer);
while (len != -1) {
bufOutstream.write(buffer, 0, len);
len = in.read(buffer);
if (Recorder.this.isCancelled) break;
}
bufOutstream.close();