java file.delete()返回false,但file.exists()返回true [英] java file.delete() returns false but file.exists() returns true

查看:697
本文介绍了java file.delete()返回false,但file.exists()返回true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图从java代码中删除一个存在于tomcat server conf / Catalina / localhost中的文件时,file.delete()总是返回false。但是,如果我通过file.exists()函数检查文件,则返回true。我没有得到任何例外。请帮助我们为什么发生这种情况。这是什么解决方案?

解决方案


当我试图删除一个存在的文件在tomcat服务器
conf / Catalina / localhost从java代码然后file.delete()总是
返回false。但是,如果我通过file.exists()函数检查文件$ ​​b $ b,它将返回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?

解决方案

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.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆