public FileDownload getFileStream(String root, String dbPath, String etag) {
try {
HttpResponse response = mClient.getFileWithVersion(root, dbPath, etag);
return new FileDownload(response);
} catch (DropboxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public File getFile(String root, String dbPath, File localFile, String etag) {
FileOutputStream fos = null;
HttpEntity entity = null;
String result = "";
try {
FileDownload response = getFileStream(root, dbPath, etag);
entity = response.entity;
// localFile = openNewLocalFile(root, dbPath);
try {
fos = new FileOutputStream(localFile);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
entity.writeTo(fos);
} catch (SocketException se) {
System.out.println(se.toString());
} catch (IOException ioe) {
System.out.println(ioe.toString());
} finally {
System.out.println("Result: " + result);
try {
if (entity != null) entity.consumeContent();
} catch (IOException ioe) {}
try {
if (fos != null) fos.close();
} catch (IOException ioe) {}
}
return localFile;
}