import java.util.ArrayList; import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; import javax.swing.JOptionPane; /** * This class serves as a simple spell checker, comparing words from a text * file to words in a dictionary, and displaying unmatched words. * @author Dave Reed * @version 2/28/05 */ public class SpellChecker { public static void main(String[] args) { String dictFile = JOptionPane.showInputDialog("Dictionary file:"); Dictionary dict = new Dictionary(dictFile); String textFile = JOptionPane.showInputDialog("Text file:"); try { System.out.println("CHECKING..."); Scanner infile = new Scanner(new File(textFile)); while (infile.hasNext()) { String word = strip(infile.next()); if (word.length() > 0 && !dict.contains(word)) { System.out.println(word); } } infile.close(); System.out.println("...DONE"); } catch (FileNotFoundException exception) { System.out.println("NO SUCH FILE FOUND"); } } private static String strip(String word) { return word; } }