【发布时间】:2013-02-26 20:29:22
【问题描述】:
我有cheerapp.wav 或cheerapp.mp3 或其他格式。
InputStream in = context.getResources().openRawResource(R.raw.cheerapp);
BufferedInputStream bis = new BufferedInputStream(in, 8000);
// Create a DataInputStream to read the audio data from the saved file
DataInputStream dis = new DataInputStream(bis);
byte[] music = null;
music = new byte[??];
int i = 0; // Read the file into the "music" array
while (dis.available() > 0) {
// dis.read(music[i]); // This assignment does not reverse the order
music[i]=dis.readByte();
i++;
}
dis.close();
对于从DataInputStream 获取数据的music 字节数组。我不知道要分配多少长度。
这是来自资源的原始文件而不是文件,因此我不知道那个东西的大小。
【问题讨论】:
-
考虑使用Apache Commons。