0

I am using Dropbox Core API to connect my Android application. But i cannot manage to download/read a file from dropbox.

I am using the following code to download and read a file but it doesn't work.

  FileOutputStream outputStream = null;
 try {
     File file = new File("/path/to/new/user.txt");
     outputStream = new FileOutputStream(file);
     mDBApi.getFile("/user.txt", null, outputStream, null);
 } catch (Exception e) {
     System.out.println("Something went wrong: " + e);
 } finally {
     if (outputStream != null) {
         try {
             outputStream.close();
         } catch (IOException e) {}
     }
 }
//This line of code reads the content of the local file that we downloaded
 InputStream instream = new FileInputStream("/path/to/new/usertxt.php");
 InputStreamReader inputreader = new InputStreamReader(instream);
 BufferedReader buffreader = new BufferedReader(inputreader);
 mTestOutput.setText(buffreader.readLine());

I get the following error

Something went wrong: java.io.FileNotFoundException: /path/to/new/user.txt: open failed: ENOENT (No such file or directory)

Could someone show me a working sample code?

3
  • I think you need to create the file first
    – ikbal
    Mar 2, 2015 at 14:57
  • But, doesn't this command do that? File file = new File("/path/to/new/user.txt"); If not, how should i do it. Please, show me a robust sample if you can.
    – kanun
    Mar 2, 2015 at 15:06
  • Have a look at this stackoverflow.com/questions/1239026/…
    – ikbal
    Mar 2, 2015 at 16:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.