2024年5月29日发(作者:)

/**

* 根据url下载

* @param request

* @param response

* @return

*/

@RequestMapping(value="/testDownload")

public ResponseEntity testDownload(HttpServletRequest

request,HttpServletResponse response){

try {

String path="D:1P_1PH9MQV102WY203_湖北移动

_M101_UMA_HB_WLW-001.015.17.11.22-HBA-A_四合一平台";

String dfileName = "";

File file = new File(path);

InputStream fis = new BufferedInputStream(new FileInputStream(file));

();

tentType("application/x-download");

der("Content-Disposition","attachment;filename="+ new

String(es(),"iso-8859-1"));

der("Content-Length", "" + ());

OutputStream toClient = new

BufferedOutputStream(putStream());

tentType("application/octet-stream");

byte[] buffer = new byte[1024 * 1024 * 4];

int i = -1;

while ((i = (buffer)) != -1) {

(buffer, 0, i);

}

();

();

();

} catch (FileNotFoundException e) {

tackTrace();

} catch (UnsupportedEncodingException e) {

// TODO Auto-generated catch block

tackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

tackTrace();

}

return null;

}

}