大家好,我有一种方法可以在我的应用程序中加密文件,我想加密文件并删除源我尝试过这样但它不起作用..?
public static void encrypt(String password, InputStream is, OutputStream os,String DelFile) throws Exception {
SecretKeySpec keySpec = new SecretKeySpec(password(password), "TripleDES");
Cipher cipher = Cipher.getInstance("TripleDES");
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
byte[] buf = new byte[8096];
os = new CipherOutputStream(os, cipher);
int numRead = 0;
while ((numRead = is.read(buf)) >= 0) {
os.write(buf, 0, numRead);
}
os.close();
// file deleting part...
File f = new File(DelFile);
f.delete();}
这个f.delete();
应该删除文件吗?我对吗?但它不会工作,请指教,谢谢。