Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I make it so after I create my file I can delete it without stopping tomcat?

Posted on 2003-11-16
4
Medium Priority
?
245 Views
Last Modified: 2010-04-01
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(szXMLString);
 filewriter1.close();
0
Comment
Question by:auduin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Expert Comment

by:neele
ID: 9761780
Something like below did u try b4??

File dir2 = new File(File.separator + "tmp" + File.separator + "test.xml");
          
if(dir2.delete())
     System.out.println("deleted");
else
     System.out.println("NOT deleted");

It shd be deleted..
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 400 total points
ID: 9764995
you write process looks good to me, I think the problem might be in your read process. I believe you must be reading it in somewhere of your java code otherwise there is no point to create it. so check out the reading code and make sure you close the inputsteam.
0
 

Author Comment

by:auduin
ID: 9767520
You are totally correct kenneth.

Forgot to do br.close() after my br.readline().

Thank your for your help
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9768362
It's my pleasure to help and glad to know your problem is solved :-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question