我尝试使用.raw
从Android外部存储目录中读取FileInputStream
音频文件。有时,我可以读取文件,有时不读。这种情况的原因是什么?
任何帮助将不胜感激。
storageDir = Environment.getExternalStorageDirectory().getAbsolutePath();
enrollWavPath = storageDir + 1 + ".raw";
File file = new File(enrollRawPath);
byte[] byteData = null;
int size = (int) file.length();
byteData = new byte[(int)(size)];
FileInputStream iFileStream = new FileInputStream(file);
int bytesread = 0;
int ret = 0;
while (bytesread < size) {
ret = iFileStream.read( byteData,0, 2*count);
if (ret != -1) {
shortData = byte2short(byteData);
bytesread += ret;
}
else {
break;
}
}
iFileStream.close();