code: public void write(@NotNull LanguageProfile languageProfile, @NotNull OutputStream outputStream) throws IOException {
          try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, Charset.forName("utf-8")))) {
              writer.write("{\"freq\":{");
              boolean first = true;
              for (Map.Entry<String, Integer> entry : languageProfile.iterateGrams()) {
                  if (!first) {
                      writer.write(',');
                  }
                  writer.write('"');
                  writer.write(entry.getKey());
                  writer.write("\":");
                  writer.write(entry.getValue().toString());
                  first = false;
              }
              writer.write("},\"n_words\":[");
              first = true;
              for (int i=1; i<=10; i++) {
                  long nWord = languageProfile.getNumGramOccurrences(i);
                  if (nWord ==0) break;
                  if (!first) {
                      writer.write(',');
                  }
                  writer.write(Long.toString(nWord));
                  first = false;
              }
              writer.write("],\"name\":\"");
              writer.write(languageProfile.getLocale().toString());
              writer.write("\"}");
              writer.flush();
          }
      }
docs: Writes a {@link LanguageProfile} to an OutputStream in UTF-8.
  
  @throws java.io.IOException