Permalink
Browse files

Fixed compiler warnings

1 parent b995517 commit d61d6f3201a9f5555a402a2327671ac3b974a159 @modmax modmax committed Jan 28, 2017
Showing with 2 additions and 24 deletions.
  1. +2 −24 yamj/src/test/java/com/moviejukebox/TestLogger.java
@@ -87,20 +87,10 @@ public static boolean configure() {
* @param propertyFile
*/
public static void loadProperties(Properties props, File propertyFile) {
- InputStream is = null;
- try {
- is = new FileInputStream(propertyFile);
+ try (InputStream is = new FileInputStream(propertyFile)) {
props.load(is);
} catch (Exception ex) {
LOG.warn("Failed to load properties file", ex);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ex) {
- LOG.warn("Failed to close properties file", ex);
- }
- }
}
}
@@ -112,26 +102,14 @@ public static void loadProperties(Properties props, File propertyFile) {
* @param headerText
*/
public static void saveProperties(Properties props, File propertyFile, String headerText) {
- OutputStream out = null;
-
- try {
- out = new FileOutputStream(propertyFile);
+ try (OutputStream out = new FileOutputStream(propertyFile)) {
if (StringUtils.isNotBlank(headerText)) {
props.store(out, headerText);
}
} catch (FileNotFoundException ex) {
LOG.warn("Failed to find properties file", ex);
} catch (IOException ex) {
LOG.warn("Failed to read properties file", ex);
- } finally {
- if (out != null) {
- try {
- out.flush();
- out.close();
- } catch (IOException ex) {
- LOG.warn("Failed to close properties file", ex);
- }
- }
}
}
}

0 comments on commit d61d6f3

Please sign in to comment.