提交 633e3a0d 编写于 作者: 如梦技术's avatar 如梦技术 🐛

完善 mica-core 工具类

上级 23c0f9d7
......@@ -68,7 +68,7 @@ public class ImageUtil {
* @return BufferedImage
*/
public static BufferedImage read(String url) {
return isHttpUrl(url) ? readUrl(url) : read(new File(url));
return StringUtil.isHttpUrl(url) ? readUrl(url) : read(new File(url));
}
/**
......@@ -77,7 +77,7 @@ public class ImageUtil {
* @param url 图片链接地址
* @return BufferedImage
*/
public static BufferedImage readUrl(String url) {
private static BufferedImage readUrl(String url) {
try {
return ImageIO.read(new URL(url));
} catch (IOException e) {
......@@ -182,8 +182,4 @@ public class ImageUtil {
return new ByteArrayInputStream(writeAsBytes(im, formatName));
}
private static boolean isHttpUrl(String text) {
return text.startsWith("http://") || text.startsWith("https://");
}
}
......@@ -56,7 +56,7 @@ public class ResourceUtil extends org.springframework.util.ResourceUtils {
if (resourceLocation.startsWith(FTP_URL_PREFIX)) {
return new UrlResource(resourceLocation);
}
if (resourceLocation.matches(HTTP_REGEX)) {
if (StringUtil.isHttpUrl(resourceLocation)) {
return new UrlResource(resourceLocation);
}
if (resourceLocation.startsWith(FILE_URL_PREFIX)) {
......
......@@ -916,5 +916,15 @@ public class StringUtil extends org.springframework.util.StringUtils {
return str.substring(pos, pos + len);
}
/**
* 判断是否 http 地址
*
* @param text 文本
* @return 是否 http 地址
*/
public static boolean isHttpUrl(String text) {
return text.startsWith("http://") || text.startsWith("https://");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册