aboutsummaryrefslogtreecommitdiffstats
path: root/vnftools/provider
diff options
context:
space:
mode:
authorsurya-huawei <a.u.surya@huawei.com>2017-10-12 14:26:36 +0530
committersurya-huawei <a.u.surya@huawei.com>2017-10-12 14:28:05 +0530
commit6bfed112851ac9d7d30fe942183a633ec9718d46 (patch)
tree61b8e5a595547de0328426e46a75b87b3cc6e687 /vnftools/provider
parent63bd422e64eb8c90167ef43bce9ef17d68dc45f3 (diff)
Use try-with-resource to close filestream
*Using try-with-resource here makes sure that the resource is automatically closed and increases code readability Issue-Id: CCSDK-117 Change-Id: Ie923e4540d5be90324104593a1d5fcb1bd501f5c Signed-off-by: surya-huawei <a.u.surya@huawei.com>
Diffstat (limited to 'vnftools/provider')
-rw-r--r--vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java17
1 files changed, 6 insertions, 11 deletions
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);
}