import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class PicInfo {
public static void main(String[] args){
InputStream is=null;
BufferedImage src=null;
try {
URL url = new URL("http://avatar.csdn.net/D/A/5/1_chiwang1984.jpg");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.connect();
is = httpConn.getInputStream(); //获取网络图片
//is=new FileInputStream("e:\\IMG_1807.JPG");//获取本地图片
src = javax.imageio.ImageIO.read(is);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int srcWidth = src.getWidth(); //得到源图宽
int srcHeight = src.getHeight(); //得到源图长
System.out.println("srcWidth="+srcWidth);
System.out.println("srcHeight="+srcHeight);
}
}