From 6b479c5774ed3d6e2dc92693ddeda3e7ad1494db Mon Sep 17 00:00:00 2001 From: Andru <769883346@qq.com> Date: 星期一, 23 十月 2023 17:34:08 +0800 Subject: [PATCH] 添加获客方法 --- src/main/java/com/hx/util/FileUtils.java | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/hx/util/FileUtils.java b/src/main/java/com/hx/util/FileUtils.java index 6911a87..7da1769 100644 --- a/src/main/java/com/hx/util/FileUtils.java +++ b/src/main/java/com/hx/util/FileUtils.java @@ -7,6 +7,7 @@ import java.io.*; import java.net.FileNameMap; +import java.net.URL; import java.net.URLConnection; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -625,5 +626,41 @@ return type; } + public static File httpUrlFile(String netUrl) throws IOException { + File file = File.createTempFile("temp123", ".xls"); + InputStream inStream = null; + FileOutputStream os = null; + + try { + file = File.createTempFile("net_url", ".jpg"); + URL urlfile = new URL(netUrl); + inStream = urlfile.openStream(); + os = new FileOutputStream(file); + + byte[] buffer = new byte[8192]; + + int bytesRead; + while((bytesRead = inStream.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + } catch (Exception var15) { + var15.printStackTrace(); + } finally { + try { + if (null != os) { + os.close(); + } + + if (null != inStream) { + inStream.close(); + } + } catch (Exception var14) { + var14.printStackTrace(); + } + + } + + return file; + } } -- Gitblit v1.8.0