File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes File Deletion is failing. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "File Deletion is failing." Watch "File Deletion is failing." New topic
Author

File Deletion is failing.

Pankaj Shet
Ranch Hand

Joined: Sep 08, 2006
Posts: 201

Hi friends,
I am trying to delete a file.
This is the program for the same.:

File f= new File(file);
boolean success=false;

if(f.exists())
{
System.out.println("File Exits: " +f.exists()+" Files Deleted:"+f.delete());

}

}

This outputs:
File Exits:true Files Deleted:false

I also checked for the appropriate permissions.
This file has all permissions.
Can any one help me regarding why this file is not getting deleted.

Any help is always appreciated.

Thanks and Regards,
-Pankaj.


PANKAJ SHET
B.Sc.(I.T.), S.C.J.P., S.C.W.C.D., PGDAC(CDAC)
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Check if you have closed all the streams accessing the file & the file is not kept opened by any other application.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1164
Please have a look at - How to tell why a file deletion fails in Java?

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Deletion is failing.
 
Similar Threads
File object does not detect xml file in a folder
File Delete Problem
Java deletion sometimes fails on Windows
Using hibernate.cfg.xml
Recursive File List - Help me problem solve please