diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2017-09-25 12:08:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-25 12:08:48 +0000 |
commit | cf8b91603edf8eaad3cb84c85a222c2e9793bf33 (patch) | |
tree | 93405d457b6bfd0aacfc00b2a7246f209ec6beec /bpmn/MSOCoreBPMN | |
parent | c5b6a14d88ee45d4152503cb429629ad172f8e83 (diff) | |
parent | 57486a2a5965511a0740eee3e2ec19610d7bfe45 (diff) |
Merge "Changed try to try with resource"
Diffstat (limited to 'bpmn/MSOCoreBPMN')
-rw-r--r-- | bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java index 1cf434052c..c2b832812e 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java @@ -312,15 +312,10 @@ public final class XmlTool { * @throws IOException if there is a problem reading the file */ private static String readResourceFile(String file) throws IOException { - InputStream stream = null; - try { - stream = XmlTool.class.getClassLoader().getResourceAsStream(file); - if (stream == null) { - throw new FileNotFoundException("No such resource file: " + file); - } + try (InputStream stream = XmlTool.class.getClassLoader().getResourceAsStream(file); + Reader reader = new InputStreamReader(stream, "UTF-8")) { - Reader reader = new InputStreamReader(stream, "UTF-8"); StringBuilder out = new StringBuilder(); char[] buf = new char[1024]; int n; @@ -328,18 +323,10 @@ public final class XmlTool { while ((n = reader.read(buf)) >= 0) { out.append(buf, 0, n); } - - stream.close(); - stream = null; return out.toString(); - } finally { - if (stream != null) { - try { - stream.close(); - } catch (Exception e) { - LOGGER.debug("Exception at readResourceFile close stream: " + e); - } - } + } catch (Exception e) { + LOGGER.debug("Exception at readResourceFile stream: " + e); + return null; } } |