- 22
- 0
- 约1.27万字
- 约 11页
- 2016-12-02 发布于湖北
- 举报
实验三 InetAddress类和URL类
一.本实验目的及要求:
熟练掌握IPv4地址分类和域名的概念;
熟练掌握InetAddress类和其生成InetAddress对象的方法(getLocalHost(),getByName(),getAllByName(),getByAddress()等);
熟练掌握URL类和其方法(getProtocol(),getHost(),getPort(),getFile(),getRef()等),可对指定的URL地址进行解析;
掌握使用System.getProperties()获得JVM系统信息;
利用new String(strValue.getBytes(“ISO8859_1”), “GBK”)构造方法,实现指定字符集之间的转换。
实验报告内容应包括,本实验的第三、四、五部分的答案,以及第六部分的程序后要求。
二、基础知识
1.InetAddress类
在网络API套接字和它的子类型对象域名系统处理主机名到主机IPv4或IPv6地址的转换。
图2-2 InetAddress类结构
由于InetAddress类只有一个构造函数,且不能传递参数,所以不能直接创建对象,比如下面的做法就是错误的:InetAddress ia = new InetAddress (); × 通过下5个方法InetAddress对象或
原创力文档

文档评论(0)