aspose file tools*
The moose likes Java in General and the fly likes Java deletion sometimes fails on Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java deletion sometimes fails on Windows" Watch "Java deletion sometimes fails on Windows" New topic
Author

Java deletion sometimes fails on Windows

Jehan Jaleel
Ranch Hand

Joined: Apr 30, 2002
Posts: 196
Hi all,
I have the following code which simply deletes a file. When I run this code in my local machine it works fine but when I run it on a batch server (a server for running standalone Java apps as batch jobs), it fails...



What could be the reason? It looks like I have write permissions, but still the file is not deleted.

Thanks for any help.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

On Windows you can't delete a file that is open for reading or writing. Probably on the server some other process or thread hasn't closed the file yet.

On UNIX you can do this, by the way; current clients of the file don't see any change, but otherwise the file disappears.


[Jess in Action][AskingGoodQuestions]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

If the file is not still open, does the file or parent folder have any rights on it that prevent you from removing it?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java deletion sometimes fails on Windows