android FileInputStream分段读取文件 断点续传
2016-10-17 14:48
946 查看
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应用开发之使用Socket进行大文件断点上传续传
- Android 使用socket通信来实现文件断点续传上传
- Android应用开发之使用Socket进行大文件断点上传续传
- Android实现文件下载断点续传
- Android应用开发之使用Socket进行大文件断点上传续传
- android大文件上传断点续传
- Android开发文件下载中的断点续传源码
- android 下载流文件的部分数据及断点续传的关键点header Range
- Android应用开发之使用Socket进行大文件断点上传续传
- Android文件下载之断点续传
- Android应用开发之使用Socket进行大文件断点上传续传
- android 读取raw下TXT文件
- C# 断点续传 上传、下载文件处理
- Android中彩信文件的读取
- IO的FileInputStream读取文件流程
- 以多线程、断点续传方式下载文件的实现
- wcf综合运用之:大文件异步断点续传
- C# 断点续传 上传、下载文件处理
- FileInputStream读取文件
- android 文件的读取与写入以及TextView的滚动