使用 J2ME 删除文件会引发 IOException

发布于 2024-07-13 01:47:28 字数 514 浏览 7 评论 0原文

我尝试使用 J2ME 的 FileConnection.delete() 方法删除文件,但每次调用 delete() 方法时都会抛出 IOException。 我编写了一个条件语句来验证文件是否存在,但不管事实如何,都会引发 IOException。

根据 FileConnection API,当对 FileConnection 对象调用 delete() 时,与该对象关联的所有流都将关闭,并且如果对与特定文件关联的流发生任何后续操作,则会引发 IOException。

我尝试删除的文件已记录在同一个程序中,但在调用delete()方法后,我调用了recordControl.reset()。 这可能会导致抛出 IOException 吗?

我的问题可能是什么?

I am attempting to delete a file using J2ME's FileConnection.delete() method, but I an IOException is being thrown each time I call the delete() method. I have written a conditional statement to verify the existence of the file, but irregardless of that fact, an IOException is thrown.

According to the FileConnection API, when delete() is called on a FileConnection object, all streams associated with the object are closed, and an IOException is thrown if any subsequent actions on the streams associated with the particular file occur.

The file I am attempting to delete has been recorded within the same program, but after I call the delete() method, I call recordControl.reset(). Would this probably cause the IOException to be thrown?

What could be my problem?

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

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

发布评论

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

评论(3

喜你已久 2024-07-20 01:47:30

我相信您的代码中的某个人已连接到您要删除的文件。 您应该手动关闭与现有文件的所有连接,并且不要相信其他人会为您执行此操作。

您是否已在其他应用程序(例如记事本)中打开该文件?

I believe that someone in your code is connected to the file you want to delete. You should manually close all connections to the existing file and not trust that someone else will do this for you.

Do you have open the file in another application, like notepad?

终难愈 2024-07-20 01:47:30

异常堆栈跟踪会告诉您哪一行代码抛出 IOException,有时您还会得到异常的原因,因此请查看堆栈跟踪。

IThe exception stack trace will tell you what line of code is throwing IOException and some times you get reason of exception as well, so have a look at the stack trace.

青柠芒果 2024-07-20 01:47:30

检查字符串,包括您传递给 Connector.open() 的路径
,验证文件权限,删除之前关闭该文件打开的所有流。

Check the string including the path that you are passing to Connector.open()
,Verify the file permissions,close all streams opened for that file before deleting.

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