NFS 驱动器上的 Java 文件删除
我正在尝试删除 NFS 驱动器上的文件。
我在操作远程驱动器上的文件时遇到了其他问题,例如移动文件 - 但是我通过不使用传统方法(即 renameFile )而是正确使用输入和输出流来解决这个问题。
然而,使用 File.delete() 返回 false ,并且我听说过有关使用 apache commons io FileUtils 类的建议 - 但它只是抛出 IO 异常。
有人对使用 java 删除网络安装驱动器上的文件有什么建议吗?
I am trying to delete a file on a NFS drive.
I have had other problems manipulating files on remote drives such as moving a file - however i got around it by not using the conventional method i.e renameFile but instead properly using input and output streams.
However using the File.delete() returns false , and I have heard suggestions on using the apache commons io FileUtils class - however it just throws an IO exception.
Does anybody have any suggestions on a way to delete a file on a network mounted drive using java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我修好了。
我没有关闭以前的缓冲读取器 - 这意味着删除无法锁定文件!
I fixed it.
I hadnt close a previous buffered reader - meaning the delete couldnt get a lock on the file!
我有类似的问题。
我有一堆 .nfs 文件很忙且无法删除。这是因为我有一个从未关闭过的 RandomFileAccess。一旦我关闭它,资源就不再繁忙。
I had a similar issue.
I had a bunch of .nfs files that were busy and couldn't delete. It was because I had a RandomFileAccess that I never closed. Once I closed it, the resource was no longer busy.