/**
* 下載圖片
* @param request
* @throws IOException
*/
@ResponseBody
@RequestMapping("downLoad.do")
public void downLoad(HttpServletRequest request, HttpServletResponse response) throws IOException {
String url = request.getParameter("pictureUrl");
String picName = url.substring(url.lastIndexOf("/")+1);
String[] split = picName.split("\\.");
//獲取文件
File file = new File(url);
//將圖片讀成二進制流
FileImageInputStream fs = new FileImageInputStream (file);
int streamLength = (int)fs.length();
byte[] image = new byte[streamLength ];
fs.read(image,0,streamLength );
fs.close();
response.setHeader("Content-Type","application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename="+split[0]+"."+split[1]);
response.getOutputStream().write(image);
response.getOutputStream().flush();
response.getOutputStream().close();
}