Skip to content

Commit

Permalink
#239 close input streams
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed Dec 6, 2023
1 parent 7c48d43 commit 6704f94
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public void triplify(Properties properties, FacadeXGraphBuilder builder) throws
// Add type Root
builder.addRoot(dataSourceId);

try (InputStream is = Triplifier.getInputStream(properties)) {
Reader in = new InputStreamReader(new BOMInputStream(is), charset);
try (InputStream is = Triplifier.getInputStream(properties); Reader in = new InputStreamReader(new BOMInputStream(is), charset)) {

Iterable<CSVRecord> records = format.parse(in);
Iterator<CSVRecord> recordIterator = records.iterator();
LinkedHashMap<Integer, String> headers_map = makeHeadersMap(recordIterator, properties, format, charset);
Expand Down Expand Up @@ -122,12 +122,18 @@ public LinkedHashMap<Integer, String> makeHeadersMap(Iterator<CSVRecord> recordI
Reader in = new InputStreamReader(new BOMInputStream(Triplifier.getInputStream(properties)), charset);
Iterable<CSVRecord> records = format.parse(in);
iterator = records.iterator();
LinkedHashMap<Integer, String> headers_map = makeHeadersMap(properties, headersRow, iterator);
in.close();
return headers_map;
}
int rowNumber = 1;
return makeHeadersMap(properties, headersRow, iterator);
}

private static LinkedHashMap<Integer, String> makeHeadersMap(Properties properties, int headersRow, Iterator<CSVRecord> iterator) {
int rowNumber = 1;
LinkedHashMap<Integer, String> headers_map = new LinkedHashMap<Integer, String>();
if (hasHeaders(properties) && iterator.hasNext()) {
while(rowNumber!=headersRow && iterator.hasNext()){
while(rowNumber!= headersRow && iterator.hasNext()){
rowNumber ++;
iterator.next();
}
Expand Down

0 comments on commit 6704f94

Please sign in to comment.