use try-with-resources statement

This commit is contained in:
stfm
2017-11-21 23:21:57 +01:00
parent 639ea26a73
commit 0cfbea3c5b
2 changed files with 13 additions and 11 deletions

View File

@@ -702,7 +702,7 @@ public class HTMLtoLaTeXBackEnd extends HTMLEditorKit.ParserCallback {
private String removeLeadingSpaces(String str) {
StringBuffer sb = new StringBuffer();
Scanner scanner = new Scanner(str);
try (Scanner scanner = new Scanner(str)) {
while (scanner.hasNextLine()) {
String l = scanner.nextLine();
if (l.startsWith(" ")) {
@@ -713,5 +713,6 @@ public class HTMLtoLaTeXBackEnd extends HTMLEditorKit.ParserCallback {
}
return sb.toString();
}
}
}

View File

@@ -470,9 +470,10 @@ public class TeXDoclet extends Doclet {
try {
FileInputStream in = new FileInputStream(args[i][2]
+ ".map");
ObjectInputStream p = new ObjectInputStream(in);
try (ObjectInputStream p = new ObjectInputStream(in)) {
Hashtable<?, ?> exref = (Hashtable<?, ?>) p.readObject();
externalrefs.put(args[i][1], exref);
}
} catch (Exception e) {
e.printStackTrace();
}