public void saveModel(OutputStream out) throws IOException {
  GZIPOutputStream zipout=new GZIPOutputStream(out);
  DataOutputStream dataout=new DataOutputStream(zipout);
  dataout.writeInt(numTopics);
  dataout.writeInt(nwz.size());
  dataout.writeDouble(alpha);
  dataout.writeDouble(beta);
  dataout.writeBoolean(locked);
  for (  Entry<String,int[]> e : nwz.entrySet()) {
    dataout.writeUTF(e.getKey());
    int[] c=e.getValue();
    for (int i=0; i < numTopics; i++) {
      dataout.writeInt(c[i]);
    }
  }
  dataout.writeInt(ntz.size());
  dataout.writeDouble(eta);
  for (  Entry<String,int[]> e : ntz.entrySet()) {
    dataout.writeUTF(e.getKey());
    int[] c=e.getValue();
    for (int i=0; i < numTopics + 1; i++) {
      dataout.writeInt(c[i]);
    }
  }
  dataout.flush();
  zipout.finish();
}

public void saveModel ( OutputStream out ) throws IOException { GZIPOutputStream zipout = new GZIPOutputStream ( out ) ; DataOutputStream dataout = new DataOutputStream ( zipout ) ; dataout . writeInt ( numTopics ) ; dataout . writeInt ( nwz . size ( ) ) ; dataout . writeDouble ( alpha ) ; dataout . writeDouble ( beta ) ; dataout . writeBoolean ( locked ) ; for ( Entry < String , int [ ] > e : nwz . entrySet ( ) ) { dataout . writeUTF ( e . getKey ( ) ) ; int [ ] c = e . getValue ( ) ; for ( int i = 0 ; i < numTopics ; i ++ ) { dataout . writeInt ( c [ i ] ) ; } } dataout . writeInt ( ntz . size ( ) ) ; dataout . writeDouble ( eta ) ; for ( Entry < String , int [ ] > e : ntz . entrySet ( ) ) { dataout . writeUTF ( e . getKey ( ) ) ; int [ ] c = e . getValue ( ) ; for ( int i = 0 ; i < numTopics + 1 ; i ++ ) { dataout . writeInt ( c [ i ] ) ; } } dataout . flush ( ) ; zipout . finish ( ) ; }
save the current model to the output stream .
