我使用Dropbox Core API连接我的Android应用程序。但是我无法从dropbox下载/读取文件。
我使用以下代码下载并阅读文件,但它不起作用。
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());
我收到以下错误
Something went wrong: java.io.FileNotFoundException: /path/to/new/user.txt: open failed: ENOENT (No such file or directory)
有人可以给我看一个有效的示例代码吗?