final Thread thread = new Thread() {
@Override
public void run() {
try {
File file = new File(path);
FileInputStream is = null;
// 获取文件大小
long length = file.length();
// 创建一个数据来保存文件数据
byte[] fileData = null;
try {
is = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int bytesRead=0;
// 读取数据到byte数组中
List<ByteArrayInputStream> temp = new ArrayList<>();
int len = 0;
fileData = new byte[1000*1000*2];
while((len=is.read(fileData))!=-1)
{
temp = new ArrayList<>();
ByteArrayInputStream byteArrayInputStream= new ByteArrayInputStream(fileData);
temp.add(byteArrayInputStream);
//上传流文件
RegisterControlService.submitVedioSon(
SubVedioViewActivity.this, temp, fInfos,subIdx);
temp.clear();
byteArrayInputStream.close();
subIdx++;
}
if(is != null)//完成后关闭输入流
is.close();
} catch (Exception ex) {
System.out.print(ex.toString()+"dujq");
String a = ex + "";
}
handler.post(callBack);
}
};
android FileInputStream分段读取文件 断点续传
最新推荐文章于 2024-05-04 12:58:01 发布