7
Am thực sự now..I frustated muốn tải về một tập tin từ Dropbox và lưu tập tin đó vào SDCARD..and Tôi đã nhận mã như:Tải tập tin từ Dropbox và lưu nó vào sdcard
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, 0, read);
}
} finally {
//in finally block:
if (bw != null) {
bw.close();
}
if (br != null) {
br.close();
}
}
return true;
}
ở đây tôi nhận được một lỗi trên BR = line..Pls BufferedInputStream mới giúp
Cũng vui lòng sao chép/dán lỗi và ngăn xếp theo dõi. –
Tôi đã sao chép dán mã này từ liên kết: http: //stackoverflow.com/questions/6180926/android-dropbox-api-file-download..Và trong mã của tôi Nó không nhận ra "fd.is" – Kanika
Bạn có chắc chắn rằng 'fd.is! = null'? –