Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
417de33e3d | ||
|
|
7dd6ec5f22 |
@@ -804,7 +804,7 @@ public static void delfile(ServletContext servletContext, String path) {
|
||||
|
||||
|
||||
/**
|
||||
* 删除字符串中提取的文件
|
||||
* 删除字符串中提取的图片文件
|
||||
*
|
||||
* @param path
|
||||
* 项目根目录下的文件路径(servletContext若null为c盘下的)
|
||||
@@ -851,6 +851,12 @@ public static void delFileForStr(ServletContext servletContext, String str) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取字符串中的图片地址存入数据库
|
||||
* @param str
|
||||
* @param towhere
|
||||
* @param saveName
|
||||
*/
|
||||
public static void intoSqlForStr(String str,String towhere,String saveName) {
|
||||
ArrayList<String> imgs = Utils.getImgStr(str, true);
|
||||
DBUtil db = new DBUtil();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package sc545.pay.utils;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -16,6 +19,7 @@ import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -1171,6 +1175,31 @@ public class Utils {
|
||||
}
|
||||
return pics;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片的宽高
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static int[] getImgWH(String url){
|
||||
int srcWidth = 0; // 源图宽度
|
||||
int srcHeight = 0; // 源图高度
|
||||
|
||||
try{
|
||||
|
||||
URL url1 = new URL(url);
|
||||
URLConnection connection = url1.openConnection();
|
||||
connection.setDoOutput(true);
|
||||
BufferedImage image = ImageIO.read(connection.getInputStream());
|
||||
if(image==null) return new int[]{0,0};
|
||||
srcWidth = image .getWidth(); // 源图宽度
|
||||
srcHeight = image .getHeight(); // 源图高度
|
||||
|
||||
}catch(Exception e){e.printStackTrace();}
|
||||
|
||||
return new int[]{srcWidth,srcHeight};
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, Object> urlParamToMaps(String q) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user