package com.dropbox.core.examples.tutorial;

import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.callbacks.DbxGlobalCallbackFactory;
import com.dropbox.core.v2.callbacks.DbxRouteErrorCallback;
import com.dropbox.core.v2.callbacks.DbxNetworkErrorCallback;
import com.dropbox.core.v2.DbxClientV2;
import com.dropbox.core.v2.files.FileMetadata;
import com.dropbox.core.v2.files.ListFolderResult;
import com.dropbox.core.v2.files.Metadata;
import com.dropbox.core.v2.users.FullAccount;

import java.util.List;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;

public class Main {
    private static final String ACCESS_TOKEN = "<ACCESS TOKEN>";

    public static void main(String args[]) throws DbxException, IOException {
        // Create Dropbox client
        DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial");
        DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);

        // Get current account info
        FullAccount account = client.users().getCurrentAccount();
        System.out.println(account.getName().getDisplayName());

        // Get files and folder metadata from Dropbox root directory
        ListFolderResult result = client.files().listFolder("");
        while (true) {
            for (Metadata metadata : result.getEntries()) {
                System.out.println(metadata.getPathLower());
            }

            if (!result.getHasMore()) {
                break;
            }

            result = client.files().listFolderContinue(result.getCursor());
        }

        // Upload "test.txt" to Dropbox
        try (InputStream in = new FileInputStream("test.txt")) {
            FileMetadata metadata = client.files().uploadBuilder("/test.txt")
                .uploadAndFinish(in);
        }
    }
}

@@ -38,16 +38,55 @@
 orial;%0A%0A
+import com.dropbox.core.DbxDownloader;%0A
 import c
@@ -618,32 +618,65 @@
 ileInputStream;%0A
+import java.io.FileOutputStream;%0A
 import java.io.I
@@ -1918,16 +1918,345 @@
        %7D
+%0A%0A        DbxDownloader%3CFileMetadata%3E downloader = client.files().download(%22/test.txt%22);%0A        try %7B%0A            FileOutputStream out = new FileOutputStream(%22test.txt%22);%0A            downloader.download(out);%0A            out.close();%0A        %7D catch (DbxException ex) %7B%0A            System.out.println(ex.getMessage());%0A        %7D
 %0A    %7D%0A%7D

Add download example to tutorial.