From fd3fb983d12879d028e95e9b46b8fc080ea0af11 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期四, 02 六月 2022 11:58:38 +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