getImage(new URL(字符串))
其使用格式可有两种:
String url = “结点URL”;
Image image;
try {
image = getImage(new URL(url));
}
catch(Exception e){
System.out.println(“Can’t open the URL “);
}
或
URL imgur=null;
Image image;
try {
imgur=new URL(“结点URL “);
}
catch (MalformedURLException e) {
System.out.println(“Can’t open the URL “);
}
image=getImage(imgur);
前一种格式用“new URL(url)”生成 URL 对象, 并直接作为getImage的参数,后一种格式先用“new URL(url)”生成一个 URL对象,再传给getImage,两种格式本质上是一样的,下