瀏覽代碼

Merge pull request #10795 from nextcloud/closeFOS

Close FOS
Andy Scherzinger 2 年之前
父節點
當前提交
423944137c
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      app/src/main/java/com/owncloud/android/ui/asynctasks/PrintAsyncTask.java

+ 8 - 1
app/src/main/java/com/owncloud/android/ui/asynctasks/PrintAsyncTask.java

@@ -73,7 +73,7 @@ public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> {
         HttpClient client = new HttpClient();
         GetMethod getMethod = null;
 
-        FileOutputStream fos;
+        FileOutputStream fos = null;
         try {
             getMethod = new GetMethod(url);
             int status = client.executeMethod(getMethod);
@@ -123,6 +123,13 @@ public class PrintAsyncTask extends AsyncTask<Void, Void, Boolean> {
             if (getMethod != null) {
                 getMethod.releaseConnection();
             }
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (IOException e) {
+                    Log_OC.e(TAG, "Error closing file output stream", e);
+                }
+            }
         }
 
         return Boolean.TRUE;