replace while with for 09/15409/1
authorHarry Huang <huangxiangyu5@huawei.com>
Tue, 26 Sep 2017 08:17:55 +0000 (16:17 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Tue, 26 Sep 2017 08:20:04 +0000 (16:20 +0800)
major: L73 L110

Change-Id: I749bd15801cec68f2eecf320e27196da6c795d3f
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Issue-Id: VNFSDK-85

vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/filemanage/http/ToolUtil.java

index 432ee21..e45d31b 100644 (file)
@@ -83,8 +83,12 @@ public class ToolUtil {
     }
     File destDir = new File(useDestDirName);
     if (destDir.exists() && overlay) {
-        new File(destDirName).delete();
-    } else if ((destDir.exists() && !overlay) || (!destDir.exists() && !destDir.mkdirs())) {
+        new File(useDestDirName).delete();
+    } else if (destDir.exists() && !overlay) {
+        return false;
+    }
+
+    if (!destDir.mkdirs()) {
         return false;
     }
 
@@ -107,11 +111,11 @@ public class ToolUtil {
       ) {
 
       byte[] buffer = new byte[1024];
-      int byteread = 0;
 
-      while ((byteread = in.read(buffer)) != -1) {
+      for (int byteread = 0; (byteread = in.read(buffer)) != -1;) {
         out.write(buffer, 0, byteread);
       }
+
       return true;
     } catch (IOException e) {
       LOGGER.error("IOException in copyFile", e);