7
我真的很frustated now..I想下载一款用于文件和保存文件到SDCARD..and我得到了代码:下载文件并将其保存到SD卡
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;
}
我在这里过得好BR错误=新的BufferedInputStream line..Pls帮助
还请复制/粘贴错误和堆栈跟踪。 – 2012-03-05 12:48:01
我有复制从链接粘贴此代码:http://stackoverflow.com/questions/6180926/android-dropbox-api-file-download...And在我的代码它不认可“fd.is” – Kanika 2012-03-05 12:49:33
你是否确定'fd.is!= null'? – 2012-03-05 12:58:58