Skip to content

Commit e7a6960

Browse files
committed
Add download example to tutorial.
1 parent 0aac92b commit e7a6960

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial

examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.dropbox.core.examples.tutorial;
22

3+
import com.dropbox.core.DbxDownloader;
34
import com.dropbox.core.DbxException;
45
import com.dropbox.core.DbxRequestConfig;
56
import com.dropbox.core.v2.callbacks.DbxGlobalCallbackFactory;
@@ -14,6 +15,7 @@
1415
import java.util.List;
1516

1617
import java.io.FileInputStream;
18+
import java.io.FileOutputStream;
1719
import java.io.InputStream;
1820
import java.io.IOException;
1921

@@ -48,5 +50,14 @@ public static void main(String args[]) throws DbxException, IOException {
4850
FileMetadata metadata = client.files().uploadBuilder("/test.txt")
4951
.uploadAndFinish(in);
5052
}
53+
54+
DbxDownloader<FileMetadata> downloader = client.files().download("/test.txt");
55+
try {
56+
FileOutputStream out = new FileOutputStream("test.txt");
57+
downloader.download(out);
58+
out.close();
59+
} catch (DbxException ex) {
60+
System.out.println(ex.getMessage());
61+
}
5162
}
5263
}

0 commit comments

Comments
 (0)