From d63d6ef6212b92848debffc676e7abb214063ec4 Mon Sep 17 00:00:00 2001 From: Janus Varmarken Date: Thu, 26 Jul 2018 18:02:41 -0700 Subject: [PATCH] TriggerTimesFileReader.java: use try-with such that trigger times file is properly closed after use --- .../java/edu/uci/iotproject/io/TriggerTimesFileReader.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java index b116909..75d06ec 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java @@ -32,9 +32,8 @@ public class TriggerTimesFileReader { */ public List readTriggerTimes(String fileName, boolean _24hFormat) { List listTriggerTimes = new ArrayList<>(); - try { - File file = new File(fileName); - BufferedReader br = new BufferedReader(new FileReader(file)); + File file = new File(fileName); + try (BufferedReader br = new BufferedReader(new FileReader(file))) { String s; while ((s = br.readLine()) != null) { listTriggerTimes.add(parseTriggerTimestamp(s, _24hFormat)); -- 2.34.1