URL编程_1.docVIP

  • 3
  • 0
  • 约5.03千字
  • 约 9页
  • 2018-01-05 发布于河南
  • 举报
URL编程_1

讲义2:URL网络编程实例 2009-11-10/11-11 Java中的URL类 (1)包含在.*中; (2)网络资源的URL为String类型。 public final class .URL extends java.lang.object{ //构造方法 //常用方法 } 其中: 1.构造方法(常用4种) (1)URL(String spec) throws MalformedURLException (2)URL(String protocol, String host, int port, String file) ~ (3)URL(String protocol, String host, String file) ~ (4)URL(URL context, String spec) ~ 注意:使用URL构造方法创建对象时,若参数有错误,会产生一个非运行时异常 MalformedURLException 举例:访问山农大信息服务页面(/sdau2005/resource.html),其URL构造: (1)new URL( /sdau2005/resource.html); (2)new URL(http, www. , 80, /sdau2005/resource.html); (3)new URL(http, www. , /sdau2005/resourc

文档评论(0)

1亿VIP精品文档

相关文档