فهرست منبع

- make sure Natives extraction closes stream

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8824 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 سال پیش
والد
کامیت
9574f9dd64
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 5 2
      engine/src/desktop/com/jme3/system/Natives.java

+ 5 - 2
engine/src/desktop/com/jme3/system/Natives.java

@@ -139,7 +139,7 @@ public class Natives {
         URLConnection conn = url.openConnection();
         InputStream in = conn.getInputStream();
         File targetFile = new File(getExtractionDir(), fullname);
-
+        OutputStream out = null;
         try {
             if (targetFile.exists()) {
                 // OK, compare last modified date of this file to 
@@ -154,7 +154,7 @@ public class Natives {
                 }
             }
 
-            OutputStream out = new FileOutputStream(targetFile);
+            out = new FileOutputStream(targetFile);
             int len;
             while ((len = in.read(buf)) > 0) {
                 out.write(buf, 0, len);
@@ -176,6 +176,9 @@ public class Natives {
             if (load) {
                 System.load(targetFile.getAbsolutePath());
             }
+            if(out != null){
+                out.close();
+            }
         }
         logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile});
     }