From f060679c86e86d1cd00aa500e2ed4dab414a686a Mon Sep 17 00:00:00 2001 From: "Cloud.Liu" Date: Wed, 8 Jul 2020 23:38:39 +0800 Subject: [PATCH] =?UTF-8?q?DEC-13978=20=E5=AE=9A=E6=97=B6=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E4=B8=8A=E4=BC=A0=E9=99=84=E4=BB=B6Okb=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=B8=AE=E5=8A=A9=E6=96=87=E6=A1=A3DEMO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/output/OutputExcel.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/fr/output/OutputExcel.java b/src/main/java/com/fr/output/OutputExcel.java index f7c87a6..72d6469 100644 --- a/src/main/java/com/fr/output/OutputExcel.java +++ b/src/main/java/com/fr/output/OutputExcel.java @@ -32,14 +32,19 @@ public class OutputExcel extends OutputActionHandler { private void output(String path) { - String realPath = ResourceIOUtils.getRealPath(path); - File file = new File(realPath); - String newPath = "C:/test/" + file.getName(); - BufferedInputStream in = null; + InputStream in = ResourceIOUtils.read(path); OutputStream out = null; + + if (in == null) { + // 读文件失败 + return; + } + try { + // 写文件到本地磁盘 + String newPath = "C:/test/" + ResourceIOUtils.getName(path); out = new BufferedOutputStream(new FileOutputStream(new File(newPath))); - in = new BufferedInputStream(new FileInputStream(realPath)); + in = new BufferedInputStream(in); byte[] ba = new byte[in.available()]; in.read(ba); out.write(ba); @@ -47,9 +52,7 @@ public class OutputExcel extends OutputActionHandler { e.printStackTrace(); } finally { try { - if (in != null) { - in.close(); - } + in.close(); if (out != null) { out.close(); }