summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-08 12:20:59 +0530
committerajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-08 12:20:59 +0530
commit1f57d5b63802e2b4d42fd4f8a5f88abe85c3964b (patch)
tree2c813c6aa88ae655ecf01b0646bc9ea281c53937
parent22ef3860bf30e0f8d2a03ab4512b96a675c34e94 (diff)
sonar fix:Resources handling in Gunzip
emsdriver/commons/utils/Gunzip.java file name: Gunzip.java Change-Id: Ia3606507c284cb37417a5da68cc4e9947816b33c Issue-ID: VFC-772 Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java15
1 files changed, 4 insertions, 11 deletions
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java
index a24afbe..89aa731 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/Gunzip.java
@@ -24,20 +24,13 @@ public class Gunzip {
*
*/
public void unCompress(String gzFileName, String toFile) throws IOException {
- try {
- FileInputStream gzInput = new FileInputStream(gzFileName);
- GZIPInputStream gzIn = new GZIPInputStream(gzInput);
+ try ( FileInputStream gzInput = new FileInputStream(gzFileName);
+ GZIPInputStream gzIn = new GZIPInputStream(gzInput)){
File tofile = new File(toFile);
enable(tofile);
- FileOutputStream fileOutput = new FileOutputStream(tofile, false);
- try{
+ try(FileOutputStream fileOutput = new FileOutputStream(tofile, false)){
moveBytes(gzIn, fileOutput, -1, -1, 1024);
- } finally {
- gzInput.close();
- gzIn.close();
- fileOutput.close();
- }
-
+ }
}catch(IOException e){
throw e;
}