help making PKCS#8 private key into PEM format?

Hi there,

I need help making my private key in pkcs#8 to pkcs#8 PEM format. I've been stuck on this for a while any help is much appreciated! I've generated my private key using with the following:

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");

keyGen.initialize(1024, new SecureRandom());

KeyPair keypair = keyGen.generateKeyPair();

PrivateKey privateKey = keypair.getPrivate();

//Write private key to file:

File file = new File("c:\\testkey.pem");

FileOutputStream fos = new FileOutputStream(file);

PrintStream pstream = new PrintStream(fos);

pstream.print(privateKey);

Output of file is below, note it is not in pem format:

Sun RSA private CRT key, 1024 bits

modulus: 980857270656774563927008658963205635602844206356319

public exponent: 65537

private exponent: 6380204380441323170149439115553268572828974246146433

prime p: 9614913087026338704176654458464550076252086418096072

prime q: 9272559205690296551290738277192022080245003521096532

prime exponent p: 1022587638640918393186299995485423957850638313542920

prime exponent q: 6079647665723363028655004406227645281110331588286280

crt coefficient: 1250838150752437749048922469455261884777542500588767

[1307 byte] By [cup_joea] at [2007-11-27 6:24:02]
# 1
I was able to figure it out and it's working now.
cup_joea at 2007-7-12 17:42:28 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...