Skip to content

Commit

Permalink
Use try-with-resources statement for FileInputStream object
Browse files Browse the repository at this point in the history
  • Loading branch information
adityatrivedi committed Sep 22, 2016
1 parent 74728de commit e6461f5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/com/sleekbyte/tailor/Tailor.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ private List<SwiftBaseListener> createListeners(Set<Rules> enabledRules,
* @return Token stream
*/
private Optional<CommonTokenStream> getTokenStream(File input) {
try {
FileInputStream inputStream = new FileInputStream(input);
try (FileInputStream inputStream = new FileInputStream(input)) {
SwiftLexer lexer = new SwiftLexer(new ANTLRInputStream(inputStream));
if (!configuration.debugFlagSet()) {
lexer.removeErrorListeners();
lexer.addErrorListener(new ErrorListener());
}
inputStream.close();
return Optional.of(new CommonTokenStream(lexer));
} catch (IOException e) {
handleIOException(e);
Expand Down

0 comments on commit e6461f5

Please sign in to comment.