当用户输入关键字后,比如cowslove然后按回车,程序依然显示在执行,无法停止,也没有继续下一步显示出计算结果。如果把while(input.hasNext()){keywords.add(input.next().toLowerCa...
当用户输入关键字后,比如 cows love 然后按回车,程序依然显示在执行,无法停止,也没有继续下一步 显示出计算结果。如果把 while(input.hasNext()){
keywords.add(input.next().toLowerCase());
}去掉while loop后只执行里面的语句,则只会执行用户输入的第一个词来计算。
public class Qurey {
public static void main(String[] args) throws FileNotFoundException{
System.out.println("please enter a file to read from: ");
Scanner in = new Scanner(System.in);
String filename = in.next();
Set textkeywords = readWords(filename);
//in.close();
System.out.println("please enter query keywords to seartch,1 to quit: ");
Set keywords = new HashSet();
Scanner input = new Scanner(System.in);
while(inp