diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/SensitiveWordDataController.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/SensitiveWordDataController.java index 49bebaa..138d111 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/SensitiveWordDataController.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/controller/cms/SensitiveWordDataController.java @@ -159,21 +159,27 @@ public class SensitiveWordDataController extends BaseController { response.setHeader("Pragma", "public"); response.setHeader("Cache-Control", "max-age=0"); InputStream in = null; + OutputStream ou =null; try { in = new FileInputStream(url); + ou = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int i = -1; + while ((i = in.read(buffer)) != -1) { + ou.write(buffer, 0, i); + } + ou.flush(); } catch (FileNotFoundException e1) { resMsg = "文件未找到"; e1.printStackTrace(); response.getWriter().write(resMsg + ":" + name); + }finally { + if (ou != null) { + ou.close(); + } + if (in != null) { + in.close(); + } } - OutputStream ou = response.getOutputStream(); - byte[] buffer = new byte[1024]; - int i = -1; - while ((i = in.read(buffer)) != -1) { - ou.write(buffer, 0, i); - } - ou.flush(); - ou.close(); - in.close(); } }