From 52c8d04a768563d8948053b74d673d79ae3d86fa Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 24 Oct 2023 10:57:17 +0800 Subject: [PATCH] =?UTF-8?q?ReadLineUtil=E5=88=A0=E9=99=A4=E4=B8=B4?= =?UTF-8?q?=E6=97=B6=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/jeecg/common/util/ReadLineUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java index 6b39656f..26a27197 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/common/util/ReadLineUtil.java @@ -44,6 +44,7 @@ public class ReadLineUtil { throw new RuntimeException("ftp连接失败!"); } InputStream iStream = null; + File file = null; try { ftpClient.enterLocalPassiveMode(); String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1); @@ -63,7 +64,7 @@ public class ReadLineUtil { //读取ftp文件的输入流 iStream=ftpClient.retrieveFileStream(ftpFile.getName()); //声明一个临时文件 - File file = File.createTempFile("betaGamma", null); + file = File.createTempFile("betaGamma", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(iStream, file); List allLines = FileUtils.readLines(file, encoding); @@ -93,6 +94,9 @@ public class ReadLineUtil { if (Objects.nonNull(iStream)){ iStream.close(); } + if (Objects.nonNull(file)) { + file.delete(); + } } catch (IOException e) { throw new RuntimeException(e); }