Used try-with-resources
Issue-ID: MUSIC-432
Change-Id: I1b2df10324fbfc100499b7de4c2414a44e232aec
Signed-off-by: jegadeeshbabu1 <jegabab1@in.ibm.com>
/*
* ============LICENSE_START==========================================
/*
* ============LICENSE_START==========================================
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modification Copyright (c) 2019 IBM
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
public static void readAndSetKeyString() {
public static void readAndSetKeyString() {
- try {
- Scanner in = new Scanner(new FileReader("/opt/app/music/etc/properties.txt"));
+ try (Scanner in = new Scanner(new FileReader("/opt/app/music/etc/properties.txt"))) {
+
StringBuilder sb = new StringBuilder();
while(in.hasNext()) {
sb.append(in.next());
}
StringBuilder sb = new StringBuilder();
while(in.hasNext()) {
sb.append(in.next());
}
keyString = sb.toString();
} catch (FileNotFoundException e) {
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
keyString = sb.toString();
} catch (FileNotFoundException e) {
logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());