// BloomTest.java import java.util.Scanner; import java.io.File; public class BloomTest { public static void main(String args[]) { // create a bloom filter of size 500,000 BloomFilter filter = new BloomFilter(500000); // check that they passed a file if (args.length != 1) { System.out.println("Please enter a dictionary file"); return; } // attempt to load the file try { Scanner in = new Scanner(new File(args[0])); while (in.hasNext()) { filter.insert(in.next()); } } catch (Exception e) { e.printStackTrace(); System.out.println("Could not read input file"); } // report words that are entered Scanner in = new Scanner(System.in); while (in.hasNext()) { String word = in.next(); if (filter.lookup(word)) { System.out.println("Yes"); } else { System.out.println("No"); } } } }