java - Cant understand the working of File object.delete() -


I am trying to delete a jar file using jar5 (hence the path API that was introduced in Java 7 Is not an option).

My code:

  string command = file. Separator; Testing file = new file ("." + + + Sep + "server" + sep + "lib" + sep + "testjar.jar"); If (test.delete ()) {logger.log (Level.INFO, test.getName () + "has been deleted".); } Else {logger.log (Level.INFO, "Delete operation" + test.getName () failed); }   

The jar file is deleted when my code is executed but the delete operation has failed for testJar.jar is printed in the log. Why Cant understand .. Any help is appreciated.

Update: I tried to redo the same code and this time it says that testJar.jar has been removed now I I am confused about what is going on

I think this problem has magically disappeared , But some common troubleshooting tips:

First of all; Try to create and delete any other file and check file permissions / ownership.

Check that there is no more process file:

  $$ Check the inherent OS call.   

file. Delete () will employ the built-in OS, and will usually end up calling (or unlink) if you use OpenJDK, you should be able to browse the source code. If not, see what happens under the "cover".

Write that this call only executes and see how the OS behaves when you try and delete this file.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -