Dictionary implements Iterable<StringList> { public static Dictionary parseOneEntryPerLine(Reader in) throws IOException { BufferedReader lineReader = new BufferedReader(in); Dictionary dictionary = new Dictionary(); String line; while ((line = lineReader.readLine()) != null) { StringTokenizer whiteSpaceTokenizer = new StringTokenizer(line, " "); String tokens[] = new String[whiteSpaceTokenizer.countTokens()]; if (tokens.length > 0) { int tokenIndex = 0; while (whiteSpaceTokenizer.hasMoreTokens()) { tokens[tokenIndex++] = whiteSpaceTokenizer.nextToken(); } dictionary.put(new StringList(tokens)); } } return dictionary; } Dictionary();  Dictionary(boolean caseSensitive);  Dictionary(InputStream in);  Dictionary(InputStream in, boolean caseSensitive); void put(StringList tokens); int getMinTokenCount(); int getMaxTokenCount(); boolean contains(StringList tokens); void remove(StringList tokens); Iterator<StringList> iterator(); int size(); void serialize(OutputStream out); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Dictionary parseOneEntryPerLine(Reader in); Set<String> asStringSet();  }
@Test public void testParseOneEntryPerLine() throws IOException { String testDictionary = "1a 1b 1c 1d \n 2a 2b 2c \n 3a \n 4a 4b "; Dictionary dictionay = Dictionary.parseOneEntryPerLine(new StringReader(testDictionary)); assertTrue(dictionay.size() == 4); assertTrue(dictionay.contains( new StringList(new String[]{"1a", "1b", "1c", "1d"}))); assertTrue(dictionay.contains( new StringList(new String[]{"2a", "2b", "2c"}))); assertTrue(dictionay.contains( new StringList(new String[]{"3a"}))); assertTrue(dictionay.contains( new StringList(new String[]{"4a", "4b"}))); }