while (scan.hasNextLine()) { //Note change
String currentLine = scan.nextLine();
//split into words
String words[] = currentLine.split(" "+",");
String words[] = currentLine.split(" ");
写成这样只能识别出空格隔开的两个word
while (scan.hasNextLine()) { //Note change
String currentLine = scan.nextLine();
//split into words
String words[] = currentLine.split(" "+",");
String words[] = currentLine.split(" ");
写成这样只能识别出空格隔开的两个word