Deleting a file using J2ME throws an IOException

I am trying to delete a file using the J2ME FileConnection.delete () method, but when I call the delete () method, I throw an IOException. I wrote a conditional statement to check for the existence of the file, but regardless of this, an IOException is thrown.

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

The file I'm trying to delete was written in one program, but after calling the delete () method, I call recordControl.reset (). Could this cause an IOException?

What could be my problem?

+3
source share
3 answers

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

Did you open the file in another application, such as notepad?

+4
source

An exception stack trace will tell you which line of code throws an IOException, and sometimes you also get the reason for the exception, so look at the stack trace.

+1
source

, , Connector.open() , , , , .

+1

Source: https://habr.com/ru/post/1702399/


All Articles