- InputStream fileInput = "文件流";
- String fileName = "文件名称.doc";
- response.setContentType("application/octet-stream");
- try {
- fileName = new String(approveFileName.getBytes("GBK"), "ISO-8859-1"));
- response.addHeader("Content-Disposition", "p_w_upload;filename=" + fileName;
- } catch (Exception e) {
- e.printStackTrace();
- }
- if(fis!=null){
- try {
- OutputStream os = response.getOutputStream();
- byte[] bytes = new byte[1024];
- int len = 0;
- while ((len = fileInput.read(bytes)) > 0) {
- os.write(bytes, 0, len);
- os.flush();
- }
- os.close();
- fileInput.close();
- response.flushBuffer();
- }catch (Exception e) {
- e.printStackTrace();
- }
- }