public void importCerts(String[] certFileNames,String aliasPrefix) throws CertificateException, IOException, KeyStoreException, NoSuchAlgorithmException {
  if (certFileNames == null) {
    return;
  }
  CertificateFactory certFactory=CertificateFactory.getInstance("X.509");
  for (  String fn : certFileNames) {
    InputStream inStream=new FileInputStream(fn);
    X509Certificate cert=(X509Certificate)certFactory.generateCertificate(inStream);
    inStream.close();
    String alias=aliasPrefix == null ? fn : aliasPrefix + fn;
    _keyStore.setCertificateEntry(alias,cert);
  }
}

public void importCerts ( String [ ] certFileNames , String aliasPrefix ) throws CertificateException , IOException , KeyStoreException , NoSuchAlgorithmException { if ( certFileNames == null ) { return ; } CertificateFactory certFactory = CertificateFactory . getInstance ( "X.509" ) ; for ( String fn : certFileNames ) { InputStream inStream = new FileInputStream ( fn ) ; X509Certificate cert = ( X509Certificate ) certFactory . generateCertificate ( inStream ) ; inStream . close ( ) ; String alias = aliasPrefix == null ? fn : aliasPrefix + fn ; _keyStore . setCertificateEntry ( alias , cert ) ; } }
import a list of certs to keystore .
