code: public static X509Certificate[] loadCertificates(String file)
              throws IOException, GeneralSecurityException {
  
          if (file == null) {
              throw new IllegalArgumentException("Certificate file is null");
              //i18n
              //                                 .getMessage("certFileNull"));
          }
  
          List<X509Certificate> list = new ArrayList<X509Certificate>();
          BufferedReader reader = new BufferedReader(new FileReader(file));
          X509Certificate cert = readCertificate(reader);
          try {
              while (cert != null) {
                  list.add(cert);
                  cert = readCertificate(reader);
              }
          } finally {
              reader.close();
          }
  
          if (list.size() == 0) {
              throw new GeneralSecurityException("No certificate data");
              //i18n.getMessage("noCertData"));
          }
  
          int size = list.size();
          return list.toArray(new X509Certificate[size]);
      }
docs: Loads multiple X.509 certificates from the specified file. Each
  certificate must be in PEM/Base64 format and start with "BEGIN
  CERTIFICATE" and end with "END CERTIFICATE" line.
  
  @param file the certificate file to load the certificate from.
  @return an array of certificates loaded from the file.
  @throws IOException              if I/O error occurs
  @throws GeneralSecurityException if security problems occurs.