@Test public void publicKey2File() throws FileNotFoundException { KeyPair keyPair = generatorKeyPair(); Converter.PublicKey2File(new FileOutputStream("/Users/robert/test.pub"), keyPair.getPublic()); }
public static void PublicKey2File(FileOutputStream stream, PublicKey publicKey) { JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(new OutputStreamWriter(stream)); try { jcaPEMWriter.writeObject(publicKey); jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } } }
Converter { public static void PublicKey2File(FileOutputStream stream, PublicKey publicKey) { JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(new OutputStreamWriter(stream)); try { jcaPEMWriter.writeObject(publicKey); jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } } } }
Converter { public static void PublicKey2File(FileOutputStream stream, PublicKey publicKey) { JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(new OutputStreamWriter(stream)); try { jcaPEMWriter.writeObject(publicKey); jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } } }  }
Converter { public static void PublicKey2File(FileOutputStream stream, PublicKey publicKey) { JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(new OutputStreamWriter(stream)); try { jcaPEMWriter.writeObject(publicKey); jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } } }  static void cert2File(X509Certificate x509Certificate, FileOutputStream fileOutputStream); static X509Certificate file2Cert(FileInputStream stream); static void PublicKey2File(FileOutputStream stream, PublicKey publicKey); static PublicKey File2PublicKey(FileInputStream stream, String algorithm); static void PrivateKey2File(FileOutputStream stream, PrivateKey privateKey); static PrivateKey File2PrivateKey(FileInputStream stream, String algorithm); static PKCS10CertificationRequest File2PKCS10CertificateRequest(FileInputStream stream); static void PKCS10CertificationRequest2File(PKCS10CertificationRequest request, FileOutputStream stream); static PrivateKey EncryptionPrivateKeyFile2PrivateKey(FileInputStream stream, String algorithm,
                                                                 String password); static void PrivateKey2EncryptionFile(FileOutputStream stream, String password, PrivateKey privateKey); static SecretKey SecureKeyFile2SecureKey(FileInputStream stream, String algorithm, Provider provider); static void SecretKey2File(SecretKey secretKey, FileOutputStream fileOutputStream); static SecretKey String2SecureKey(String var1, String algorithm, Provider provider); static String PublicKey2String(PublicKey publicKey); static String PrivateKey2String(PrivateKey privateKey); static PublicKey String2PublicKey(String var, String algorithm); static PrivateKey String2PrivateKey(String var, String algorithm); }
Converter { public static void PublicKey2File(FileOutputStream stream, PublicKey publicKey) { JcaPEMWriter jcaPEMWriter = new JcaPEMWriter(new OutputStreamWriter(stream)); try { jcaPEMWriter.writeObject(publicKey); jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { jcaPEMWriter.close(); } catch (IOException e) { e.printStackTrace(); } } }  static void cert2File(X509Certificate x509Certificate, FileOutputStream fileOutputStream); static X509Certificate file2Cert(FileInputStream stream); static void PublicKey2File(FileOutputStream stream, PublicKey publicKey); static PublicKey File2PublicKey(FileInputStream stream, String algorithm); static void PrivateKey2File(FileOutputStream stream, PrivateKey privateKey); static PrivateKey File2PrivateKey(FileInputStream stream, String algorithm); static PKCS10CertificationRequest File2PKCS10CertificateRequest(FileInputStream stream); static void PKCS10CertificationRequest2File(PKCS10CertificationRequest request, FileOutputStream stream); static PrivateKey EncryptionPrivateKeyFile2PrivateKey(FileInputStream stream, String algorithm,
                                                                 String password); static void PrivateKey2EncryptionFile(FileOutputStream stream, String password, PrivateKey privateKey); static SecretKey SecureKeyFile2SecureKey(FileInputStream stream, String algorithm, Provider provider); static void SecretKey2File(SecretKey secretKey, FileOutputStream fileOutputStream); static SecretKey String2SecureKey(String var1, String algorithm, Provider provider); static String PublicKey2String(PublicKey publicKey); static String PrivateKey2String(PrivateKey privateKey); static PublicKey String2PublicKey(String var, String algorithm); static PrivateKey String2PrivateKey(String var, String algorithm);  }