public void save(File keyStore,String type,char[] password,char[] keyPassword,String caAlias) throws GeneralSecurityException, IOException {
  KeyStore store=KeyStore.getInstance(type);
  store.load(null,password);
  store.setKeyEntry(caAlias,caKey,keyPassword,caCerts);
  OutputStream out=new FileOutputStream(keyStore);
  try {
    store.store(out,password);
  }
 catch (  IOException ioe) {
    ioe.printStackTrace();
  }
 finally {
    out.close();
  }
}

public void save ( File keyStore , String type , char [ ] password , char [ ] keyPassword , String caAlias ) throws GeneralSecurityException , IOException { KeyStore store = KeyStore . getInstance ( type ) ; store . load ( null , password ) ; store . setKeyEntry ( caAlias , caKey , keyPassword , caCerts ) ; OutputStream out = new FileOutputStream ( keyStore ) ; try { store . store ( out , password ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } finally { out . close ( ) ; } }
saves the ca key and the certificate chain to the specified keystore
