From f435b7cb4d5a078c5387c91888c782e1936a5881 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Thu, 11 Mar 2021 15:40:42 +0800
Subject: [PATCH] 新增申请成为分销员接口2

---
 zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java b/zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java
index c7fdbdb..d6966a2 100644
--- a/zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java
+++ b/zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java
@@ -2,8 +2,10 @@
 
 import java.awt.*;
 import java.awt.image.BufferedImage;
-import java.io.FileNotFoundException;
-import java.io.IOException;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -91,4 +93,44 @@
 		System.out.println("系统字体数:" + fontCount);
 	}
 
+
+	public static void downloadPicture(String imgUrl,String savePath) {
+		URL url = null;
+		int imageNumber = 0;
+		try {
+
+			InputStream inputStream = null;
+			HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(imgUrl).openConnection();
+			httpURLConnection.setRequestMethod("GET");
+			httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36");
+			httpURLConnection.setRequestProperty("Accept-Encoding", "gzip");
+			httpURLConnection.setRequestProperty("Referer","no-referrer");
+			httpURLConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
+			httpURLConnection.setConnectTimeout(15000);
+			httpURLConnection.setReadTimeout(20000);
+			inputStream = httpURLConnection.getInputStream();
+
+
+
+			FileOutputStream fileOutputStream = new FileOutputStream(new File(savePath));
+			ByteArrayOutputStream output = new ByteArrayOutputStream();
+			byte[] buffer = new byte[1024];
+			int length;
+			while ((length = inputStream.read(buffer)) > 0) {
+				output.write(buffer, 0, length);
+			}
+			byte[] context=output.toByteArray();
+			fileOutputStream.write(output.toByteArray());
+			inputStream.close();
+			fileOutputStream.close();
+		} catch (MalformedURLException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+
+
+
 }

--
Gitblit v1.9.1