From f8ab5663ef7220f8adc0fd8fcbd7d0cf84c6d77d Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期一, 02 八月 2021 12:15:14 +0800
Subject: [PATCH] update 日常字符串校验 统一重构到 StringUtils 便于维护扩展

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java |  204 +++++++++++++++++++++++++-------------------------
 1 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java
index 94dcf45..632a21e 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java
@@ -1,102 +1,102 @@
-package com.ruoyi.common.utils.file;
-
-import cn.hutool.core.util.StrUtil;
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import org.apache.poi.util.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Arrays;
-
-/**
- * 鍥剧墖澶勭悊宸ュ叿绫�
- *
- * @author ruoyi
- */
-public class ImageUtils
-{
-    private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
-
-    public static byte[] getImage(String imagePath)
-    {
-        InputStream is = getFile(imagePath);
-        try
-        {
-            return IOUtils.toByteArray(is);
-        }
-        catch (Exception e)
-        {
-            log.error("鍥剧墖鍔犺浇寮傚父 {}", e);
-            return null;
-        }
-        finally
-        {
-            IOUtils.closeQuietly(is);
-        }
-    }
-
-    public static InputStream getFile(String imagePath)
-    {
-        try
-        {
-            byte[] result = readFile(imagePath);
-            result = Arrays.copyOf(result, result.length);
-            return new ByteArrayInputStream(result);
-        }
-        catch (Exception e)
-        {
-            log.error("鑾峰彇鍥剧墖寮傚父 {}", e);
-        }
-        return null;
-    }
-
-    /**
-     * 璇诲彇鏂囦欢涓哄瓧鑺傛暟鎹�
-     * 
-     * @param key 鍦板潃
-     * @return 瀛楄妭鏁版嵁
-     */
-    public static byte[] readFile(String url)
-    {
-        InputStream in = null;
-        ByteArrayOutputStream baos = null;
-        try
-        {
-            if (url.startsWith("http"))
-            {
-                // 缃戠粶鍦板潃
-                URL urlObj = new URL(url);
-                URLConnection urlConnection = urlObj.openConnection();
-                urlConnection.setConnectTimeout(30 * 1000);
-                urlConnection.setReadTimeout(60 * 1000);
-                urlConnection.setDoInput(true);
-                in = urlConnection.getInputStream();
-            }
-            else
-            {
-                // 鏈満鍦板潃
-                String localPath = RuoYiConfig.getProfile();
-                String downloadPath = localPath + StrUtil.subAfter(url, Constants.RESOURCE_PREFIX,false);
-                in = new FileInputStream(downloadPath);
-            }
-            return IOUtils.toByteArray(in);
-        }
-        catch (Exception e)
-        {
-            log.error("鑾峰彇鏂囦欢璺緞寮傚父 {}", e);
-            return null;
-        }
-        finally
-        {
-            IOUtils.closeQuietly(in);
-            IOUtils.closeQuietly(baos);
-        }
-    }
-}
+package com.ruoyi.common.utils.file;
+
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.StringUtils;
+import org.apache.poi.util.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Arrays;
+
+/**
+ * 鍥剧墖澶勭悊宸ュ叿绫�
+ *
+ * @author ruoyi
+ */
+public class ImageUtils
+{
+    private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
+
+    public static byte[] getImage(String imagePath)
+    {
+        InputStream is = getFile(imagePath);
+        try
+        {
+            return IOUtils.toByteArray(is);
+        }
+        catch (Exception e)
+        {
+            log.error("鍥剧墖鍔犺浇寮傚父 {}", e);
+            return null;
+        }
+        finally
+        {
+            IOUtils.closeQuietly(is);
+        }
+    }
+
+    public static InputStream getFile(String imagePath)
+    {
+        try
+        {
+            byte[] result = readFile(imagePath);
+            result = Arrays.copyOf(result, result.length);
+            return new ByteArrayInputStream(result);
+        }
+        catch (Exception e)
+        {
+            log.error("鑾峰彇鍥剧墖寮傚父 {}", e);
+        }
+        return null;
+    }
+
+    /**
+     * 璇诲彇鏂囦欢涓哄瓧鑺傛暟鎹�
+     *
+     * @param key 鍦板潃
+     * @return 瀛楄妭鏁版嵁
+     */
+    public static byte[] readFile(String url)
+    {
+        InputStream in = null;
+        ByteArrayOutputStream baos = null;
+        try
+        {
+            if (url.startsWith("http"))
+            {
+                // 缃戠粶鍦板潃
+                URL urlObj = new URL(url);
+                URLConnection urlConnection = urlObj.openConnection();
+                urlConnection.setConnectTimeout(30 * 1000);
+                urlConnection.setReadTimeout(60 * 1000);
+                urlConnection.setDoInput(true);
+                in = urlConnection.getInputStream();
+            }
+            else
+            {
+                // 鏈満鍦板潃
+                String localPath = RuoYiConfig.getProfile();
+                String downloadPath = localPath + StringUtils.subAfter(url, Constants.RESOURCE_PREFIX,false);
+                in = new FileInputStream(downloadPath);
+            }
+            return IOUtils.toByteArray(in);
+        }
+        catch (Exception e)
+        {
+            log.error("鑾峰彇鏂囦欢璺緞寮傚父 {}", e);
+            return null;
+        }
+        finally
+        {
+            IOUtils.closeQuietly(in);
+            IOUtils.closeQuietly(baos);
+        }
+    }
+}

--
Gitblit v1.9.3