问题描述
当我试图从java代码中删除一个存在于tomcat server conf / Catalina / localhost中的文件时,file.delete()总是返回false。但是,如果我通过file.exists()函数检查文件,则返回true。我没有得到任何例外。请帮助我们为什么发生这种情况。这是什么解决方案?
有权限用于删除服务器上的文件。检查您的权限。
$ b $ p 删除()返回false这意味着它不是/不能删除和 f.exists()
返回true,所以文件存在,但无法删除。
When I am trying to delete a file which is present in tomcat server conf/Catalina/localhost from java code then file.delete() always returns false. But if I am checking the file by file.exists() function it returns true. I am not getting any exception. Please help us why this is happening. What is the solution for this?
Most likely you do not have permission for deleting file(s) on Server. Check your permissions.
f.delete()
returns false it means that it wasn't / could not be deleted and f.exists()
returns true so file exists but cannot be deleted.
这篇关于java file.delete()返回false,但file.exists()返回true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!