Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with deleting a file  RSS feed

 
Subha Rangu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been trying to delete a file using File class's delete method.
In my application, I am creating files using File.write method dynamically.after some point I would like to delete the same file which can be captured by the user's action. I am suing delete of File class and it seems to be not working. Can someone help mein this regard.
My code:
In jsp page:
-----------------------------------------------------------------
<%
File fname=(File)session.getAttribute("opFile");
String str="c:/onDemand/"+fname.getName();
File fname1=new File(str);
System.out.println(fname1);
System.out.println("isdelete?"+fname1.delete());
%>
--------------------------------------------------
and output I got @console:
-----------------------------------------------------------------------------
c:\onDemand\xxAlH414kHOgUn9FACSs27z00489568.tif
isdelete?false
-------------------------------------------------
But I can see the file ,its neither getting deleted nor throwing an exception.
Please help me....Thanks
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any Input/OutputStream or Reader/Writer instances which access the file and are not closed?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!