935090232@qq.com
2022-02-17 94f76200c0ac4d87e73afa4895f6088bfb02b6b2
zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java
@@ -3,6 +3,7 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -97,18 +98,30 @@
      URL url = null;
      int imageNumber = 0;
      try {
         url = new URL(imgUrl);
         DataInputStream dataInputStream = new DataInputStream(url.openStream());
         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 = dataInputStream.read(buffer)) > 0) {
         while ((length = inputStream.read(buffer)) > 0) {
            output.write(buffer, 0, length);
         }
         byte[] context=output.toByteArray();
         fileOutputStream.write(output.toByteArray());
         dataInputStream.close();
         inputStream.close();
         fileOutputStream.close();
      } catch (MalformedURLException e) {
         e.printStackTrace();