public Dictionary(Directory tempDir,String tempFileNamePrefix,InputStream affix,List<InputStream> dictionaries,boolean ignoreCase) throws IOException, ParseException {
  this.ignoreCase=ignoreCase;
  this.needsInputCleaning=ignoreCase;
  this.needsOutputCleaning=false;
  flagLookup.add(new BytesRef());
  Path aff=Files.createTempFile(tempPath,"affix","aff");
  OutputStream out=new BufferedOutputStream(Files.newOutputStream(aff));
  InputStream aff1=null;
  InputStream aff2=null;
  boolean success=false;
  try {
    final byte[] buffer=new byte[1024 * 8];
    int len;
    while ((len=affix.read(buffer)) > 0) {
      out.write(buffer,0,len);
    }
    out.close();
    aff1=new BufferedInputStream(Files.newInputStream(aff));
    String encoding=getDictionaryEncoding(aff1);
    CharsetDecoder decoder=getJavaEncoding(encoding);
    aff2=new BufferedInputStream(Files.newInputStream(aff));
    readAffixFile(aff2,decoder);
    IntSequenceOutputs o=IntSequenceOutputs.getSingleton();
    Builder<IntsRef> b=new Builder<>(FST.INPUT_TYPE.BYTE4,o);
    readDictionaryFiles(tempDir,tempFileNamePrefix,dictionaries,decoder,b);
    words=b.finish();
    aliases=null;
    morphAliases=null;
    success=true;
  }
  finally {
    IOUtils.closeWhileHandlingException(out,aff1,aff2);
    if (success) {
      Files.delete(aff);
    }
 else {
      IOUtils.deleteFilesIgnoringExceptions(aff);
    }
  }
}

public Dictionary ( Directory tempDir , String tempFileNamePrefix , InputStream affix , List < InputStream > dictionaries , boolean ignoreCase ) throws IOException , ParseException { this . ignoreCase = ignoreCase ; this . needsInputCleaning = ignoreCase ; this . needsOutputCleaning = false ; flagLookup . add ( new BytesRef ( ) ) ; Path aff = Files . createTempFile ( tempPath , "affix" , "aff" ) ; OutputStream out = new BufferedOutputStream ( Files . newOutputStream ( aff ) ) ; InputStream aff1 = null ; InputStream aff2 = null ; boolean success = false ; try { final byte [ ] buffer = new byte [ 1024 * 8 ] ; int len ; while ( ( len = affix . read ( buffer ) ) > 0 ) { out . write ( buffer , 0 , len ) ; } out . close ( ) ; aff1 = new BufferedInputStream ( Files . newInputStream ( aff ) ) ; String encoding = getDictionaryEncoding ( aff1 ) ; CharsetDecoder decoder = getJavaEncoding ( encoding ) ; aff2 = new BufferedInputStream ( Files . newInputStream ( aff ) ) ; readAffixFile ( aff2 , decoder ) ; IntSequenceOutputs o = IntSequenceOutputs . getSingleton ( ) ; Builder < IntsRef > b = new Builder < > ( FST . INPUT_TYPE . BYTE4 , o ) ; readDictionaryFiles ( tempDir , tempFileNamePrefix , dictionaries , decoder , b ) ; words = b . finish ( ) ; aliases = null ; morphAliases = null ; success = true ; } finally { IOUtils . closeWhileHandlingException ( out , aff1 , aff2 ) ; if ( success ) { Files . delete ( aff ) ; } else { IOUtils . deleteFilesIgnoringExceptions ( aff ) ; } } }
creates a new dictionary containing the information read from the provided inputstreams to hunspell affix and dictionary files . you have to close the provided inputstreams yourself .
