mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
ensure closing of scanner if it was opened
This commit is contained in:
parent
0da4e10c49
commit
7b3d6a60b6
1 changed files with 6 additions and 1 deletions
|
@ -957,10 +957,11 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
}
|
||||
|
||||
protected final void getSuggestedActions() {
|
||||
Scanner scanner = null;
|
||||
try {
|
||||
File file = new File(FILE_WITH_INSTRUCTIONS);
|
||||
if (file.exists()) {
|
||||
Scanner scanner = new Scanner(file);
|
||||
scanner = new Scanner(file);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
if (line.startsWith("cast:")
|
||||
|
@ -976,6 +977,10 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
|
|||
} catch (Exception e) {
|
||||
// swallow
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(scanner != null) {
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue