/** * @Description 下载文件 * @author zhangyd
* @date 2015年12月11日 下午6:11:33
* @param fileName
* @param file
* @return
* @throws IOException */
public ResponseEntity download(String fileName, File file) throws IOException {
String dfileName = new String(fileName.getBytes("gb2312"), "iso8859-1");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", dfileName);
return new ResponseEntity(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED); }
spring下载简洁代码
最新推荐文章于 2024-08-08 17:46:27 发布