X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vnftools%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fsdnc%2Fvnftools%2FVnfTools.java;h=08ed43534fbad9976dd20b5153adbafb3ac53fb4;hb=6bfed112851ac9d7d30fe942183a633ec9718d46;hp=fb95a41fc807cf4f75bba918fbb12f5697e2bbc1;hpb=63bd422e64eb8c90167ef43bce9ef17d68dc45f3;p=sdnc%2Fnorthbound.git diff --git a/vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java b/vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java index fb95a41f..08ed4353 100644 --- a/vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java +++ b/vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java @@ -162,18 +162,13 @@ public class VnfTools implements SvcLogicJavaPlugin { } PrintStream pstr = null; - FileOutputStream fileStream = null; - try { - pstr = new PrintStream(fileStream = new FileOutputStream(new File(fileName), true)); - } catch (Exception e) { - if (fileStream != null) { - try { - fileStream.close(); - } catch (IOException e1) { - LOG.error("FileOutputStream close exception: ", e1); - } - } + try (FileOutputStream fileStream = new FileOutputStream(new File(fileName), true)){ + pstr = new PrintStream(fileStream); + } catch (IOException e1) { + LOG.error("FileOutputStream close exception: ", e1); + } + catch (Exception e) { throw new SvcLogicException("Cannot open file " + fileName, e); }