This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Delete problem

 
imran ghani
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m trying to delete a file through my servlet
using the following code.
File file1 = new File(s);
boolean flag1 = file1.delete();
if(!flag1){
printwriter.println("Can't Delete " + s + "
<br>");
return "false";
}
printwriter.println("deleted Successfully <br>");

s is a string variable containing path
s = "img/20-December-2002/101_heading.gif"
Alway's give me message can't delete file.Although file exists at this path.
Please give some solution...
Imran Ghani.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13047
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you have expressed the path without a root implies that it is relative to the "current" directory, but in a servlet you have no control over the current directory.
Bill
 
Michael Bronshteyn
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sure the user who runs servlet container has permission to delete the file ( write permission ).
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dear
i go with michael, check for the "Permission", i do create a lot of problem if not set properly.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic