Skip to content

Commit

Permalink
Duplicate detector
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabor Angeli authored and Stanford NLP committed Sep 17, 2015
1 parent 062b39f commit bd8d04a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/edu/stanford/nlp/io/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2059,10 +2059,10 @@ public static void deleteRecursively(File file) {
* @param callback The function to run for every line of input.
* @throws IOException Thrown from the underlying input stream.
*/
public static void console(Consumer<String> callback) throws IOException {
public static void console(String prompt, Consumer<String> callback) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
System.out.print("> ");
System.out.print(prompt);
while ( (line = reader.readLine()) != null) {
switch (line.toLowerCase()) {
case "exit":
Expand All @@ -2071,10 +2071,15 @@ public static void console(Consumer<String> callback) throws IOException {
default:
callback.accept(line);
}
System.out.print("> ");
System.out.print(prompt);
}
}

/** @see IOUtils#console(String, Consumer) */
public static void console(Consumer<String> callback) throws IOException {
console("> ", callback);
}

/**
* Create a prompt, and read a single line of response.
* @param prompt An optional prompt to show the user.
Expand Down

0 comments on commit bd8d04a

Please sign in to comment.