* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.clamp.clds.util;
* Return resource as a String.
*/
public static String getResourceAsString(String name) throws IOException {
- InputStream is = getResourceAsStream(name);
- Scanner scanner = new Scanner(is);
- Scanner delimitedScanner = scanner.useDelimiter("\\A");
- String text = delimitedScanner.hasNext() ? delimitedScanner.next() : "";
- delimitedScanner.close();
- scanner.close();
- is.close();
- return text;
+ try (InputStream is = getResourceAsStream(name)) {
+ try (Scanner scanner = new Scanner(is)) {
+ Scanner delimitedScanner = scanner.useDelimiter("\\A");
+ return delimitedScanner.hasNext() ? delimitedScanner.next() : "";
+ }
+ }
}
}