public class WordFilter
{
/**
* Searches the data file and prints out the stats of the file.
*/
public static void wordFilter(String[] arg)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the pattern you want to search for: ");
String pattern = keyboard.nextLine();
try{
int matches = 0;
Scanner in = new Scanner(new File("words.txt"));
while(in.hasNextLine()) {
String word = in.nextLine();
word = word.trim();
}
System.out.println();
if(matches == 0) {
System.out.println("There are no matches.");
} else {
System.out.println("There are " + matches + " matches.");
}
}catch(Exception e)
{
System.out.println(e.toString());
}
}
}
