Hi,
I'm working in an application using Tomcat and servlets.
There is a servlet (audioProcess) that receives the name of an mp3 file, that is played. This servlet also processes the mp3 file and stores the result in a txt file. The content of this txt will be replaced when the audioProcess servlet is invoked again (with a different mp3 file).
Everytime this servlet is invoked I delete the txt and I create a new one (containing information regarding the mp3 file). The name of the txt file is always the same.
My problem is that the txt file is never deleted. What I do to delete the file is:
File a = new File(path_clasificacion);
if(a.exists())
{
boolean erased = a.delete();
out.println("erased?" + erased);
}
The first time I invoke the servlet the txt file is erased. Only the first time. After deleting the txt file I try to write the new information in a txt file with the same name (stored in the same path). What happens is that the old file is not erased, the new information is added to the file.
Why can't I delete the file?
Thanks
The txt file is generated using this code:
FileWriter f = null;
PrintWriter pw = null;
try
{
f = new FileWriter(path,true);
pw = new PrintWriter(f);
pw.println(info);
} catch (Exception e) {e.printStackTrace();
finally
{
f.close();
}