code: public static void writeVocabCache(@NonNull VocabCache<VocabWord> vocabCache, @NonNull OutputStream stream)
              throws IOException {
          try (PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8)))) {
              // saving general vocab information
              writer.println("" + vocabCache.numWords() + " " + vocabCache.totalNumberOfDocs() + " " + vocabCache.totalWordOccurrences());
  
              for (int x = 0; x < vocabCache.numWords(); x++) {
                  VocabWord word = vocabCache.elementAtIndex(x);
                  writer.println(word.toJSON());
              }
          }
      }
docs: This method saves vocab cache to provided OutputStream.
  Please note: it saves only vocab content, so it's suitable mostly for BagOfWords/TF-IDF vectorizers
  
  @param vocabCache
  @param stream
  @throws UnsupportedEncodingException