Here you can find the source of getPublicKey(final byte[] keyData)
private static PublicKey getPublicKey(final byte[] keyData) throws GeneralSecurityException
//package com.java2s; //License from project: Apache License import java.security.GeneralSecurityException; import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; public class Main { private static PublicKey getPublicKey(final byte[] keyData) throws GeneralSecurityException { final X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyData); final KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePublic(keySpec); }/* w ww.j a va 2s. c o m*/ }