我创建了一个KeyStore对象,并在其中存储了一个SecretKey。然后我将KeyStore保存到文件中。当我尝试阅读KeyStore时,它是空的。为什么它是空的?
KeyStore keystore = KeyStore.getInstance("JCEKS");
char[] password = "password".toCharArray();
keystore.load(null,password);
KeyGenerator keygen = KeyGenerator.getInstance("AES");
keygen.init(256);
SecretKey key = keygen.generateKey();
KeyStore.SecretKeyEntry ske = new KeyStore.SecretKeyEntry(key);
KeyStore.ProtectionParameter pp = new KeyStore.PasswordProtection(password);
keystore.setEntry("superman", ske, pp);
FileOutputStream fos = new FileOutputStream(Directory.KEY);
keystore.store(fos,password);
fos.close();