code: public static PublicKey decodePublicKey(String pemEncoded) throws Exception {
          pemEncoded = removeBeginEnd(pemEncoded);
          byte[] encodedBytes = Base64.getDecoder().decode(pemEncoded);
  
          X509EncodedKeySpec spec = new X509EncodedKeySpec(encodedBytes);
          KeyFactory kf = KeyFactory.getInstance("RSA");
          return kf.generatePublic(spec);
      }
docs: Decode a PEM encoded public key string to an RSA PublicKey
  
  @param pemEncoded - PEM string for private key
  @return PublicKey
  @throws Exception on decode failure