/** * Writes the given WikiWord to the output stream. * * @param word The word to write * @param dataOut The stream to write to * @throws IOException */ private void writeWikiWord(WikiWord word, DataOutputStream dataOut) throws IOException { /* * Serialization format is as follows: * (String) name of the word * (String) wiki text * (int) number of child words * (WikiWord) child 1 * ... repeat for each child */ dataOut.writeUTF(word.getName()); dataOut.writeUTF(word.getWikiText()); List children = word.getWikiWords(); log.debug("Word has " + children.size() + " children"); dataOut.writeInt(children.size()); for (int i = 0, size = children.size(); i < size; ++i) { writeWikiWord((WikiWord) children.get(i), dataOut); } }