From db1b408d60e2f4d0c48bc875a09ab4c8a2975367 Mon Sep 17 00:00:00 2001
From: ChenJiaHe <763432473@qq.com>
Date: 星期六, 05 三月 2022 14:45:39 +0800
Subject: [PATCH] 新增文件导出工具方法-流模式

---
 src/main/java/com/hx/util/FileUtil.java |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/FileUtil.java b/src/main/java/com/hx/util/FileUtil.java
index 03e7fee..69a7d41 100644
--- a/src/main/java/com/hx/util/FileUtil.java
+++ b/src/main/java/com/hx/util/FileUtil.java
@@ -1,6 +1,9 @@
 package com.hx.util;
 
+import org.apache.commons.io.FileUtils;
+
 import java.io.*;
+import java.net.URL;
 
 /**
  * 鏂囦欢璇诲彇宸ュ叿绫�
@@ -10,6 +13,23 @@
 public class FileUtil {
 
     /**
+     * @param pathUrl 缃戠粶璺緞
+     * @return 鏂囦欢
+     */
+    public static File getUrlFile(String pathUrl){
+        File temp = null;
+        try{
+            URL url = new URL(pathUrl);
+            temp = File.createTempFile("temp", ".xls");
+            FileUtils.copyURLToFile(url, temp);
+            temp.deleteOnExit();
+        }catch (Exception e){
+            throw new RuntimeException("閫氳繃URL鑾峰彇鏂囦欢鍑洪敊",e);
+        }
+        return temp;
+    }
+
+    /**
      * 璇诲彇鏂囦欢鍐呭锛屼綔涓哄瓧绗︿覆杩斿洖
      */
     public static String readFileAsString(String filePath) throws IOException {

--
Gitblit v1.8.0