File f = new File("c://a.txt");
BufferedInputStream bis =new BufferedInputStream(new FileInputStream(f));
byte[] buffer = new byte[1024];
response.setContentType("application/octet-stream");
//定义下载文件的名字
String a = new String(z.getZiname().getBytes("utf-8"),"iso8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + a+"c://a.txt".substring("c://a.txt".lastIndexOf(".")) + "\"");
OutputStream os = response.getOutputStream();
int len = -1;
while((len=bis.read(buffer))!=-1){
os.write(buffer, 0, len);
}
os.flush();
os.close();
bis.close();