我创建了一个属性文件,我想加密保留相同的文件夹加密属性文件并删除原始属性文件.当我第一次在我的java应用程序上执行此操作时,它确实正确.但是,当我再次执行此操作时,它不会删除创建的原始属性文件.当我尝试手动删除它时,它再次尝试消息说"由于文件在java(TM)平台SE二进制文件中打开,因此操作无法完成.关闭文件并重试." 关闭我的应用程序后,可以手动删除它.我的代码如下.问题在于propfile123.delete().我该如何解决这个问题.
//Encrypt the property file
Encrypt_Decrypt encrpt= new Encrypt_Decrypt("AES/ECB/PKCS5Padding","properties\\"+name_of_propertice_file+".properties", mstr_pass);
try {
encrpt.encrypt();
} catch (Exception ex) {
Logger.getLogger(Secure_File.class.getName()).log(Level.SEVERE, null, ex);
}
//delete the original properties file
File propfile123= new File("properties\\"+name_of_propertice_file+".properties");
System.out.println(propfile123.exists()); // always return true
System.out.println(propfile123.delete()); //here returns false when I call at second time to this method.
Run Code Online (Sandbox Code Playgroud) 网络具有 n 层协议层次结构。应用程序生成长度为 M 字节的消息。在每一层,都添加了一个 h 字节的标头。报头填充了网络带宽的哪一部分?请向我解释答案。
当我使用以下代码创建文件时,它不会输出可见文件.它不会给出任何异常.在以下代码中存在输出.这意味着文件实际存在.但我看不出来.实际上这里发生了什么?
File file= new File("/folder/abc.txt");
if(file.exist)
System.out.println("exist");
Run Code Online (Sandbox Code Playgroud)