我正在将Video Uri转换为字节数组,但出现FileNotFoundException
我已经编写了将Video Uri转换为字节数组的代码
video = data.getData();
byte[] buf = new byte[1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis;
try {
fis = new FileInputStream(new File(video.getPath()));
int n;
while (-1 != (n = fis.read(buf)))
baos.write(buf, 0, n);
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
bbytes= baos.toByteArray();
答案 0 :(得分:0)
尝试使用ContentResolver
打开流:
fis = context.getContentResolver().openInputStream(video);