views:

1052

answers:

4

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?

A: 

Could you post the stack trace?

maskefjes
A: 

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.

Bhushan
+2  A: 

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?

Markus Lausberg
That's what it was for me, when I had this. Assuming you're running in the WTK emulator.
izb
A: 

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.

Jinesh