/**
*
* @param imgUrl 图片地址
* @return
*/
public static BufferedImage getBufferedImage(String imgUrl) {
URL url = null;
InputStream is = null;
BufferedImage img = null;
try {
url = new URL(imgUrl);
is = url.openStream();
img = ImageIO.read(is);
} catch (MalformedURLException e) {
} catch (IOException e) {
} finally {
try {
if(is != null){
is.close();
}
} catch (IOException e) {
}
}
return img;
}
public static void main(String[] args) {
BufferedImage image = getBufferedImage("http://192.168.1.99:8080/walks/img/1HU9BE56G000.jpg");
System.out.println(image.getWidth()+"-------"+image.getHeight());
}
java 通过网络地址获取图片宽高
最新推荐文章于 2023-04-01 10:10:42 发布