auduin
asked on
How do I make it so after I create my file I can delete it without stopping tomcat?
The code below creates a file called test.xml in C:\tmp. The problem im having is that I cant delete the file without stopping tomcat first. Gives me the windows error message "Cannot delete test:it is being used by another person or program".
How do I make it so after I create my file I can delete it without stopping tomcat?
Thanks in advance.
File dir = new File(File.separator + "tmp");
dir.mkdirs();
FileWriter filewriter1 = new FileWriter(File.separator + "tmp" + file.separator + "test.xml");
String szXMLString="this is a test";
filewriter1.write(szXMLStr ing);
filewriter1.close();
How do I make it so after I create my file I can delete it without stopping tomcat?
Thanks in advance.
File dir = new File(File.separator + "tmp");
dir.mkdirs();
FileWriter filewriter1 = new FileWriter(File.separator + "tmp" + file.separator + "test.xml");
String szXMLString="this is a test";
filewriter1.write(szXMLStr
filewriter1.close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are totally correct kenneth.
Forgot to do br.close() after my br.readline().
Thank your for your help
Forgot to do br.close() after my br.readline().
Thank your for your help
It's my pleasure to help and glad to know your problem is solved :-)
File dir2 = new File(File.separator + "tmp" + File.separator + "test.xml");
if(dir2.delete())
System.out.println("delete
else
System.out.println("NOT deleted");
It shd be deleted..