Here you can find the source of getPublicKey(String publicKeyFile)
public static RSAPublicKey getPublicKey(String publicKeyFile)
//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; } }