
private boolean downloadDropBoxfile(String dbPath,file localfile) throws IOException{BufferedinputStream br = null;bufferedoutputstream bw = null;try { if (!localfile.exists()) { localfile.createNewfile(); //otherwise dropBox clIEnt will fail silently } fileDownload fd = API.getfileStream("dropBox",dbPath,null); **br = new BufferedinputStream(fd.is);** bw = new bufferedoutputstream(new fileOutputStream(localfile)); byte[] buffer = new byte[4096]; int read; while (true) { read = br.read(buffer); if (read <= 0) { break; } bw.write(buffer,read); }} finally { //in finally block: if (bw != null) { bw.close(); } if (br != null) { br.close(); }}return true; }
这里我在br = new BufferedinputStream line..Pls帮助中收到错误
解决方法 我找到了方法:file file= new file("/sdcard/New_csv_file.csv"); OutputStream out= null; boolean result=false; try { out = new bufferedoutputstream(new fileOutputStream(file)); } catch (fileNotFoundException e1) { // Todo auto-generated catch block e1.printstacktrace(); } try { DropBoxfileInfo info = mAPI.getfile("/photos/New_csv_file.csv",null,out,null); Log.i("DbExampleLog","The file's rev is: " + info.getMetadata().rev); Intent JumptoparseCSV=new Intent(context,ParseCSV.class); JumptoparseCSV.putExtra("filename",file.getabsolutePath()); Log.i("path","filename"+ file.getabsolutePath()); ((Activity) context).finish(); context.startActivity(JumptoparseCSV); result=true; } catch (DropBoxException e) { Log.e("DbExampleLog","Something went wrong while downloading."); file.delete(); result=false; } return result; 谢谢大家….
总结以上是内存溢出为你收集整理的android – 从Dropbox下载文件并将其保存到SDCARD全部内容,希望文章能够帮你解决android – 从Dropbox下载文件并将其保存到SDCARD所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)