java file.delete()返回false,但file.exists()返回true

编程入门 行业动态 更新时间:2024-10-27 18:26:53
本文介绍了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

本文发布于:2023-06-08 14:28:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583075.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:delete   file   java   true   exists

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!