Skip to content

Commit

Permalink
Try-with-resources fix
Browse files Browse the repository at this point in the history
  • Loading branch information
berk76 committed Oct 31, 2020
1 parent 5aea904 commit d6043e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/cz/webstones/words/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,23 @@ public static Setup getSetup(boolean createLocalCopy, String dictPath) {
}

private static Setup loadSetup(File f, String dictPath, Setup setup) throws IOException {
InputStream is;
Properties props = new Properties();

if (setup == null) {
setup = new Setup();
}

if (f != null) {
is = new FileInputStream(f);
try (InputStream is = new FileInputStream(f)) {
props.load(is);
}
} else {
Class cls = Setup.class;
ClassLoader cLoader = cls.getClassLoader();
is = cLoader.getResourceAsStream("setup.properties");
try (InputStream is = cLoader.getResourceAsStream("setup.properties")) {
props.load(is);
}
}

props.load(is);
is.close();

setup.setDataDir(dictPath);

Expand Down

0 comments on commit d6043e7

Please sign in to comment.