import javax.swing.*;
import java.net.*;
public class Test{
public static void main(String args[])
throws Exception{
URL url=new URL("http://hao123.com/logox.gif");
ImageIcon ic=new ImageIcon(url);
System.out.println(ic.getDescription());
System.out.println(ic.getIconHeight());
}
}可以啊,我测试了
import java.net.*;
public class Test{
public static void main(String args[])
throws Exception{
URL url=new URL("http://hao123.com/logox.gif");
ImageIcon ic=new ImageIcon(url);
System.out.println(ic.getDescription());
System.out.println(ic.getIconHeight());
}
}可以啊,我测试了
可是为什么本地tomcat服务器上取资源建对象却不成功呢?
启动tomcat5.0后,把
URL url=new URL("http://hao123.com/logox.gif");
改成
URL=new URL("http://localhost:8080/ChatRoom_ServerVersion/head.jpg");
就得不到图像了
磁盘文件是以大写".JPG"结尾,而本人用的java语句中用的是小写".jpg"
谢谢killme2008
送分