diff options
-rw-r--r-- | src/main/Analyzor.java | 5 | ||||
-rw-r--r-- | src/main/FarmShell.java | 13 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/main/Analyzor.java b/src/main/Analyzor.java index 9be1101..b4fbae7 100644 --- a/src/main/Analyzor.java +++ b/src/main/Analyzor.java @@ -2,6 +2,7 @@ package main; import database.NamedPreparedStatement; import database.QueryUtils; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.sql.Connection; @@ -43,8 +44,8 @@ public class Analyzor { // A unigram is in the format (WS = whitespace): // word <WS> rating <WS> ??? <WS> ?? // A bigram has an two WS-separated words instead of one. - try (Scanner uniScanner = new Scanner("unigrams-pmilexicon.txt"); - Scanner biScanner = new Scanner("bigrams-pmilexicon.txt");) { + try (Scanner uniScanner = new Scanner(new File("unigrams-pmilexicon.txt")); + Scanner biScanner = new Scanner(new File("bigrams-pmilexicon.txt"));) { //Fill the map of unigrams while (uniScanner.hasNext()) { String words = uniScanner.next(); diff --git a/src/main/FarmShell.java b/src/main/FarmShell.java index 3c6f17f..7186c2f 100644 --- a/src/main/FarmShell.java +++ b/src/main/FarmShell.java @@ -64,8 +64,6 @@ public class FarmShell { // print prompt for reading next line printPrompt(); } - // prevent corrupted compressed files when exiting without a command - throw new NoSuchElementException(); } /** @@ -102,8 +100,13 @@ public class FarmShell { System.err.println("Command " + args[0] + " failed with " + ex); ex.printStackTrace(); } catch (NoSuchElementException ex) { - // thrown by the "exit" command to signal exit - return false; + if ("EXIT NOW".equals(ex.getMessage())) { + // thrown by the "exit" command to signal exit + return false; + } else { + System.err.println("ZOMG SOMETHIGN FAILED: " + ex.getMessage()); + ex.printStackTrace(); + } } catch (SQLException ex) { System.err.println("such " + ex); } @@ -145,7 +148,7 @@ public class FarmShell { } break; case exit: - throw new NoSuchElementException(); + throw new NoSuchElementException("EXIT NOW"); default: throw new AssertionError(command.name()); } |