<% @ Page Language = "Java" %>
<% @ Page session = "true" %>
<% @ Page isthreadsafe = "true" %>
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<% @ Page import = "Java. Io. *, java. util. *" %>
 
 
 
<%
 
String filereallyname = request. getparameter ("file ");
 
File zipfile = new file (filereallynam );
 
If (! Zipfile. exist ()){
 
Out. Print ("the file does not exist ");
 
Return;
 
}
 
Response. setcontenttype ("application/X-msdownload; charset = gb2312 ");
Response. setheader ("content-disposition", "attachment; filename =/" "+ new string (filereallyname. getbytes ("GBK"), "ISO8859-1") + "/"");
Fileinputstream FCM = NULL;
Bytearrayoutputstream Bos = NULL;
Try
{
FS = new fileinputstream (zipfile );
Bos = new bytearrayoutputstream (8192 );
Int Readline;
Byte [] B = new byte [1024];
While (Readline = FS. Read (B ))! =-1)
Bos. Write (B, 0, Readline );
Bos. writeto (response. getoutputstream ());
Out. Clear ();
Out = pagecontext. pushbody ();
} Catch (ioexception E)
{
 
Out. Print ("Download error" + E. getmessage ());
} Finally {
Try {
If (FS! = NULL) FCM. Close ();
If (Bos! = NULL) Bos. Close ();
} Catch (exception e ){
Out. Print ("failed to close the file stream ");
}
}
 
%>