diff options
-rw-r--r-- | src/io/DataWriter.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/io/DataWriter.java b/src/io/DataWriter.java index d762fee..2e90097 100644 --- a/src/io/DataWriter.java +++ b/src/io/DataWriter.java @@ -97,8 +97,9 @@ public class DataWriter implements ResultListener { */ private Set<Long> readIds(Store store) throws IOException { Set<Long> idSet = new HashSet<>(); + InputStream is = null; try { - InputStream is = store.getInputStream(); + is = store.getInputStream(); Scanner reader = new Scanner(is); // parse each line into a JSONObject, read the id and add it to // the set of ids. @@ -112,6 +113,14 @@ public class DataWriter implements ResultListener { } catch (JSONException ex) { getLogger().log(Level.WARNING, store.getFileName() + ": File is only partially processed", ex); + } finally { + try { + if (is != null) { + is.close(); + } + } catch (IOException ex) { + getLogger().log(Level.WARNING, "Cannot close input file", ex); + } } return idSet; } |