Java 如果dropbox中已经存在文件,如何覆盖该文件?

Java 如果dropbox中已经存在文件,如何覆盖该文件?,java,android,dropbox,Java,Android,Dropbox,我正在通过以下方法在dropbox中上载文件: public void upload() { FileInputStream inputStream = null; try { File file = new File(Environment.getExternalStorageDirectory() .toString() + "/write.txt"); inputStr

我正在通过以下方法在dropbox中上载文件:

public void upload() {

        FileInputStream inputStream = null;
        try {
            File file = new File(Environment.getExternalStorageDirectory()
                    .toString() + "/write.txt");
            inputStream = new FileInputStream(file);
            Entry newEntry = mDBApi.putFile("/write.txt", inputStream,
                    file.length(), null, null);
            Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
        } catch (DropboxUnlinkedException e) {
            // User has unlinked, ask them to link again here.
            Log.e("DbExampleLog", "User has unlinked.");
        } catch (DropboxException e) {
            Log.e("DbExampleLog", "Something went wrong while uploading.");
        } catch (FileNotFoundException e) {
            Log.e("DbExampleLog", "File not found.");
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                }
            }
        }

    }
但当文件夹中已经存在此文件时,该文件将被重命名为write(1).txt
但我想,如果文件已经存在于dropbox共享文件夹中,那么它将被替换。现在我该怎么办?

您可以使用
mDBApi.putFileOverwrite
而不是
mDBApi.putFile

您是否尝试过
file.exists()
function否,但如果这样做有效,我该怎么做才能覆盖以前的?@reiley
file.exists()
在网络上无法覆盖Dropbox。