response.reset();
response.setContentType("application/octet-stream; charset=UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=image");
InputStream in = null;
try {
in = new FileInputStream(thubFile);
OutputStream os = response.getOutputStream();
byte[] buffer = new byte[1024];
int len;
while((len = in.read(buffer)) > 0){
os.write(buffer, 0, len);
}
os.flush();
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
转载于:https://my.oschina.net/sfilyh/blog/83991