<%
String filename ="D:/t.txt";
String filecopy = "t.txt";
java.io.BufferedInputStream bis = null;
java.io.BufferedOutputStream bos = null;
try{
File f = new File(filename);
response.reset();
OutputStream os = response.getOutputStream();
response.setContentType("application/x-msdownload");
response.setContentType("application/vnd.wap.wmlc");
response.setHeader("Content-disposition",
"attachment; filename=/"" + filecopy + "/"");
response.setContentLength((int) f.length());
bis = new java.io.BufferedInputStream(
new java.io.FileInputStream(filename));
bos = new java.io.BufferedOutputStream(os);
byte[] buff = new byte[1024];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff,0, bytesRead);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
%>