Java Security Programming question

I am having a bit of trouble using the KeyStore class to save an encrypted key to disk. My specific error is as follows “KeyStoreException: java.io.IOException: Error initialising store of key store.” the lines that create this are:

"
KeyStore ks_out = KeyStore.getInstance(“BKS”,“BC”);
ks_out.load(null,null);
ks_out.setKeyEntry(“priv_key”,key_to_save,password.toCharArray(),cert_array);

ks_out.store(bos,password.toCharArray());
"

ks_out.setKeyEntry(“priv_key”,key_to_save,password.toCharArray(),cert_array);
is where the exception spawns from.

Basically I just need to know what is missing/ what I am doing wrong, because I’ve reread the JavaDoc again and again to no avail. Thanks!!

-Mike