我被困在这个小复杂的情况下。我正在编写 android 应用程序的一部分,我正在将 Mp3 文件读入多个字节数组。问题是这个字节数组的数量将由来自 USB 的文本文件以及每个字节数组的大小决定。请给我一个出路。
下面是我正在读取 Mp3 文件的代码
cxt = ControlUnit.getAppContext();
try {
File file = new File("/mnt/media/USBDISK1/IFrame_00.bin");
input = new BufferedInputStream(new FileInputStream(file));
//input = cxt.getAssets().open("Maid with the Flaxen Hair.mp3");
Log.i("TvPlayerFunctionalTestApp", "mp3 file Read from Assests");
} catch (IOException e) {
// TODO Auto-generated catch block
Log.i("TvPlayerFunctionalTestApp", "Error in Opening mp3 File");
e.printStackTrace();
}
try {
size = input.available();
Log.i("TvPlayerFunctionalTestApp", "Size of Bin File: "+size);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
buffer = new byte[AClipTextFileHandler.BufferSize.get(0)];
input.read(buffer);
// input.read(buffer, offset, length);
Log.i("TvPlayerFunctionalTestApp", "buffer: "+ Arrays.toString(buffer));
buffer1 = new byte[AClipTextFileHandler.BufferSize.get(1)];
input.read(buffer1);
Log.i("TvPlayerFunctionalTestApp", "buffer: "+ Arrays.toString(buffer1));
StringBuffer stringBuff = new StringBuffer();
for (byte b:buffer)
{
stringBuff.append(String.format("%x", b));
}
Log.i("TvPlayerFunctionalTestApp","buffer: "+stringBuff) ;
for (byte b:buffer1)
{
stringBuff.append(String.format("%x", b));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.i("TvPlayerFunctionalTestApp", "Error in Read");
}
try {
input.close();
Log.i("TvPlayerFunctionalTestApp", "File closed");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我无法理解如何List<Byte> arrays = new ArrayList<Byte>()
帮助我。