Java Key Public getPublicKey(String publicKeyFile)

Here you can find the source of getPublicKey(String publicKeyFile)

Description

get Public Key

License

Apache License

Declaration

public static RSAPublicKey getPublicKey(String publicKeyFile) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.FileInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

import java.security.interfaces.RSAPublicKey;

public class Main {
    public static RSAPublicKey getPublicKey(String publicKeyFile) {
        ObjectInputStream publicKeyInputStream;
        try {// w w w  .j av a2 s . c  om
            publicKeyInputStream = new ObjectInputStream(new FileInputStream(publicKeyFile));
            RSAPublicKey publicKey = (RSAPublicKey) publicKeyInputStream.readObject();
            publicKeyInputStream.close();
            return publicKey;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. getPublicKey(String filename)
  2. getPublicKey(String filename)
  3. getPublicKey(String key)
  4. getPublicKey(String modulus, String exponent)
  5. getPublicKey(String publicKeyContents)
  6. getPublicKey(String publicKeyFilepath, String algorithm)
  7. getPublicKeyFromBytes(final String algorithm, final byte[] publicKeyBytes)
  8. getPublicKeyFromFile(File cert, String alias, String password)
  9. getPublicKeyFromPEMFile(String fileName, String jceProvider)