File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Deletion is failing.

 
Pankaj Shet
Ranch Hand
Posts: 289
Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at - How to tell why a file deletion fails in Java?

Regards,
Dan
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic