@RequestMapping (value = "/download")
public void DownLoad (httpservletresponse response, String value,string oldname, String datefilename) throws parseexception{
String path =uploadsdir+folder+ "/attach/" +datefilename+ "/" +value;
File File = new file (path);
InputStream fis;
try {
string filename = new string (Oldname.getbytes ("iso-8859-1"), "Utf-8");
FIS = new Bufferedinputstream (new FileInputStream (path));
byte[] buffer = new byte[fis.available ()];
Fis.read (buffer);
Fis.close ();
Response.reset ();
Response.AddHeader ("Content-disposition", "attachment;filename=" + New String (Filename.replaceall ("", ""). GetBytes ( "Utf-8"), "iso8859-1");
Response.AddHeader ("Content-length", "" "+ File.length ());
OutputStream OS = new Bufferedoutputstream (Response.getoutputstream ());
Response.setcontenttype ("Application/octet-stream");
Os.write (buffer);
Os.flush ();
Os.close ();
} catch (Exception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
Java File download