code: public static PGPPublicKey getPublicKey(InputStream content) throws Exception {
          InputStream in = PGPUtil.getDecoderStream(content);
          PGPPublicKeyRingCollection keyRingCollection = new PGPPublicKeyRingCollection(in, new BcKeyFingerprintCalculator());
          PGPPublicKey key = null;
          Iterator<PGPPublicKeyRing> keyRings = keyRingCollection.getKeyRings();
          while(key == null && keyRings.hasNext()) {
              PGPPublicKeyRing keyRing = keyRings.next();
              Iterator<PGPPublicKey> keys = keyRing.getPublicKeys();
              while(key == null && keys.hasNext()) {
                  PGPPublicKey current = keys.next();
                  if(current.isEncryptionKey()) {
                      key = current;
                  }
              }
          }
          return key;
      }
docs: Extracts the PGP public key from an encoded stream.
  @param content stream to extract the key
  @return key object
  @throws IOException if there is an error reading the stream
  @throws PGPException if the public key cannot be extracted