Title: Downloading and then delete the downloaded files
For downloading you could try this code
 
<%
// fetch the file
String filename = "companySecret.txt";
String filepath = "C:\\";
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=\""   + filename + "\"");

java.io.FileInputStream fileInputStream =  new java.io.FileInputStream(filepath + filename);
int i;
while ((i=fileInputStream.read()) != -1) {
     out.write(i);
}
fileInputStream.close();
out.close();
%>
 
Deleting the file from the server.
You could check if the file exists using File class in java.io.File. exists() method returns a boolean whether file exists or not.
If it returns true delete the file using delete() method.

Regards,
Vikramjit Singh,
GTL Ltd.
Ph. 7612929-1059

-----Original Message-----
From: Michael Reilly [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 12, 2002 1:35 PM
To: [EMAIL PROTECTED]
Subject: Downloading and then delete the downloaded files

Hi,
Any ideas on how a servlet would download files from the server to the client and then , based on whether the download was valid, delete the file from the server.

Mike

Reply via email to