diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2018-02-20 11:08:11 +0530 |
---|---|---|
committer | Kanagaraj Manickam <kanagaraj.manickam@huawei.com> | 2018-02-20 11:46:01 +0000 |
commit | 8f02ba857cd0afff5f9e86351b525629ca850128 (patch) | |
tree | 6ae57da5f35fa6dc6311104743977e211786ba14 /huawei/vnfmadapter/VnfmadapterService/service | |
parent | 63c6439895ce75c376fe6f0f71f223538f10d379 (diff) |
Close the stream properly
Issue-ID: VFC-764
Change-Id: I6ec52e49877e3a8bcc55fd2e91f05cfe52473d4e
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'huawei/vnfmadapter/VnfmadapterService/service')
-rw-r--r-- | huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java index 2cbd1ab8..b09c50d7 100644 --- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java +++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/common/DownloadCsarManager.java @@ -192,17 +192,17 @@ public class DownloadCsarManager { if(parent != null && (!parent.exists())) { parent.mkdirs(); } - FileOutputStream fos = new FileOutputStream(file); - BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER); + try(FileOutputStream fos = new FileOutputStream(file)){ + try(BufferedOutputStream bos = new BufferedOutputStream(fos, BUFFER)){ - int count; - byte data[] = new byte[BUFFER]; - while((count = bis.read(data, 0, BUFFER)) != -1) { - bos.write(data, 0, count); + int count; + byte data[] = new byte[BUFFER]; + while((count = bis.read(data, 0, BUFFER)) != -1) { + bos.write(data, 0, count); + } + bos.flush(); + } } - bos.flush(); - bos.close(); - bis.close(); } status = Constant.UNZIP_SUCCESS; |