@Override protected void putWordUnique(String arg0) { super.putWord(arg0); } };
/** * Constructs the dictionary from a word list file. * <p> * Each word in the reader should be on a separate line. * <p> * This is a very slow function. On my machine it takes quite a while to * load the data in. I suspect that we could speed this up quite allot. */ protected void createDictionary(BufferedReader in) throws IOException { // robert: Optimized ever-so-slightly String line; while ((line=in.readLine())!=null) { if (line.length() > 0) { putWord(line); } } }
/** * Add a word permanently to the dictionary (and the dictionary file). * <p>This needs to be made thread safe (synchronized)</p> */ public boolean addWord(String word) { putWord(word); if (dictFile!=null) { try { // Append new word to user's word file BufferedWriter w = new BufferedWriter(new FileWriter(dictFile, true)); w.write(word); w.write("\n"); w.close(); return true; } catch (IOException ex) { System.out.println("Error writing to dictionary file"); ex.printStackTrace(); } } // Only return true if added to dictionary file. return false; }