用于关闭在 java(TM) 平台 SE 二进制文件中打开的文件的 Java 代码

发布于 2024-11-08 16:33:43 字数 177 浏览 0 评论 0原文

我的应用程序中有用于删除文件的java代码,即nameOffile.delete()。当我尝试删除该文件时,出现错误:该操作无法完成,因为该文件是在 Java (TM) Platform SE 二进制文件中打开的。关闭文件并重试。我尝试在没有应用程序的情况下删除文件,但仍然遇到同样的问题。请帮我解决这些错误。

先感谢您!!

I have java code in my application for deleting a file i.e nameOffile.delete(). As I try to delete the file I get an error: The action can not be completed because the file is open in Java (TM) Platform SE binary. Close the file and try again. I tried deleting the file without the application but I still get the same problem. Please help me solve thes error.

Thank you in advance!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老子叫无熙 2024-11-15 16:33:43

您可能首先打开文件来读取/写入其内容?
您可能忘记关闭流。因此您无法删除它。

Writer out = new OutputStreamWriter(new FileOutputStream(fileName), fEncoding);
try {
  out.write("some text here");
}
finally {
  out.close();
}

// write code to delete the file

You were probably opening the file first to read/write its content?
There you probably forgot to close the stream. Therefore you are not able to delete it.

Writer out = new OutputStreamWriter(new FileOutputStream(fileName), fEncoding);
try {
  out.write("some text here");
}
finally {
  out.close();
}

// write code to delete the file
尐籹人 2024-11-15 16:33:43

要解决此问题,请打开任务管理器并关闭 java,然后您就可以删除该文件

To solve this problem open task manager and close java then you'll be able to delete the file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文