Eclipse IFile: Create not called when jar is deleted

66 views Asked by At

I have a method that checks if a file exists then it deletes the file but will always create a new file (Jar file). I am using the org.eclipse.core.resources.IFile class for create and delete methods.

The code looks like this:

if(file != null){
   if(file.exists()){
       file.delete(true, monitor);
       system.out.println("File deleted");
     }
     system.out.println("File creation starting");
     file.create(stream, true, null);
     system.out.println("File created");
   }

Problem: When the jar file is existing, it calls the delete method but fails to call the other methods like the logs and the create method. But when I debug the whole process step by step it succeeds.

Example of scenarios for this issue

Scenario 1: Jar file is not in folder. It doesn't call the delete method. Calls the create method only. Build is successful.

Scenario 2: Jar file is already in the folder. It calls the delete method. Continues with the program without calling the create method or the sysout logs. Build fails.

Scenario 3: Jar file is already in the folder. Debug mode step by step. It calls the delete method and calls the create method. Build is successful.

May I know what am I missing? I tried to put a wait after the delete method and it succeeds but I don't think its the best solution for this problem.

0

There are 0 answers