code: public void persist(File file) throws IOException {
      //System.err.println("Writting "+wordMap.size()+" words and "+gramSet.size()+" n-grams");
      DataOutputStream output = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
      output.writeUTF(FILE_TYPE);
      System.err.println("pruning from "+wordMap.size());
      for (Iterator ki=wordMap.iterator();ki.hasNext();) {
        String key = (String) ki.next();
        if (((CountedNumberedSet) wordMap).getCount(key) < cutoff) {
          ki.remove();
        }
      }
      System.err.println("pruning to "+wordMap.size());
      output.writeInt(wordMap.size());
      for (Iterator ki=wordMap.iterator();ki.hasNext();) {
        String key = (String) ki.next();
        output.writeUTF(key);
        output.writeInt(wordMap.getIndex(key));
      }
      CountedSet cset = (CountedSet) gramSet;
      int gramCount = 0;
      for (Iterator gi = gramSet.iterator();gi.hasNext();) {
        NGram ngram = (NGram) gi.next();
        if (cset.getCount(ngram) >= cutoff) {
          int[] words = ngram.getWords();
          output.writeInt(words.length);
          for (int wi=0;wi<words.length;wi++) {
            output.writeInt(words[wi]);
          }
          gramCount++;
        }
        else {
          //System.err.println("ngram "+cset.getCount(ngram));
        }
      }
      System.err.println("Wrote out "+gramCount+" n-grams");
      output.close();
    }
docs: Save this n-gram dictionary to the specified file.
  @param file The file to store the n-gram dictionary.
  @throws IOException If the file can not be written.