tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anne Milbert" <anne.milb...@freenet.de>
Subject Howto delete a file with a servlet???
Date Wed, 07 Dec 2005 16:13:22 GMT
Hi anyone,

I'd like to delete a file with a servlet. I tried it with the delete()
function and with the runtime.exec() function. What am I doing wrong?

Here's my code:
Solution 1:
[...]
String cmd = "del C:\\" + request.getParameter("Id") + "-" + eleno + ".xml";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(datname)
[...]

Solution 2:
[...]
String datname = "C:\\" + request.getParameter("Id") + "-" + eleno + ".xml";
boolean success = (new File("datname")).delete();
if (!success) {
	out.println("Couldn't delete file: " + datname);
}
[...]

Regards,
Anne


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message