public static void save(KeyStore keyStore,File keyStoreFile,Password password) throws CryptoException, IOException {
  KeyStoreType keyStoreType=KeyStoreType.resolveJce(keyStore.getType());
  if (!keyStoreType.isFileBased()) {
    throw new CryptoException(MessageFormat.format(res.getString("NoSaveKeyStoreNotFile.exception.message"),keyStoreType.jce()));
  }
  FileOutputStream fos=null;
  fos=new FileOutputStream(keyStoreFile);
  try {
    keyStore.store(fos,password.toCharArray());
  }
 catch (  IOException ex) {
    throw new CryptoException(res.getString("NoSaveKeyStore.exception.message"),ex);
  }
catch (  KeyStoreException ex) {
    throw new CryptoException(res.getString("NoSaveKeyStore.exception.message"),ex);
  }
catch (  CertificateException ex) {
    throw new CryptoException(res.getString("NoSaveKeyStore.exception.message"),ex);
  }
catch (  NoSuchAlgorithmException ex) {
    throw new CryptoException(res.getString("NoSaveKeyStore.exception.message"),ex);
  }
 finally {
    IOUtils.closeQuietly(fos);
  }
}

public static void save ( KeyStore keyStore , File keyStoreFile , Password password ) throws CryptoException , IOException { KeyStoreType keyStoreType = KeyStoreType . resolveJce ( keyStore . getType ( ) ) ; if ( ! keyStoreType . isFileBased ( ) ) { throw new CryptoException ( MessageFormat . format ( res . getString ( "NoSaveKeyStoreNotFile.exception.message" ) , keyStoreType . jce ( ) ) ) ; } FileOutputStream fos = null ; fos = new FileOutputStream ( keyStoreFile ) ; try { keyStore . store ( fos , password . toCharArray ( ) ) ; } catch ( IOException ex ) { throw new CryptoException ( res . getString ( "NoSaveKeyStore.exception.message" ) , ex ) ; } catch ( KeyStoreException ex ) { throw new CryptoException ( res . getString ( "NoSaveKeyStore.exception.message" ) , ex ) ; } catch ( CertificateException ex ) { throw new CryptoException ( res . getString ( "NoSaveKeyStore.exception.message" ) , ex ) ; } catch ( NoSuchAlgorithmException ex ) { throw new CryptoException ( res . getString ( "NoSaveKeyStore.exception.message" ) , ex ) ; } finally { IOUtils . closeQuietly ( fos ) ; } }
save a keystore to a file protected by a password .
