⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right8_2_3.htm

📁 清华大学JAVA教程
💻 HTM
字号:
<html><head><title>JAVA编程语言</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="stylesheet" href="../../../css/text.css" type="text/css"></head><body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">  <tr>     <td valign="top">       <table width="97%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" align="center">        <tr>          <td height="244" valign="top">             <p class="pt9-black">   为了表示URL, java.net中实现了类URL。我们可以通过下面的构造方法来初始化一个URL对象:<br>                (1) public URL (String spec);<br>                   通过一个表示URL地址的字符串可以构造一个URL对象。<br>                   URL urlBase=new URL(&quot;http://www. 263.net/&quot;) <br>              <br>                (2) public URL(URL context, String spec);<br>                   通过基URL和相对URL构造一个URL对象。<br>                   URL net263=new URL (&quot;http://www.263.net/&quot;);<br>                   URL index263=new URL(net263, &quot;index.html&quot;)<br>              <br>                (3) public URL(String protocol, String host, String file);<br>                   new URL(&quot;http&quot;, &quot;www.gamelan.com&quot;, &quot;/pages/Gamelan.net.               html&quot;);<br>              <br>                (4) public URL(String protocol, String host, int port, String               file);<br>                   URL gamelan=new URL(&quot;http&quot;, &quot;www.gamelan.com&quot;,               80, &quot;Pages/Gamelan.network.html&quot;);</p>            <p class="pt9-black">  <b><font color="000099">注意:</font></b>类URL的构造方法都声明抛弃非运行时例外(MalformedURLException),因此生成URL对象时,我们必须要对这一例外进行处理,通常是用try-catch语句进行捕获。格式如下:<br>            </p>            <span class="pt9-black">   try{<br>                 URL myURL= new URL(…)<br>              }catch (MalformedURLException e){<br>              …<br>              <font color="339900">//exception handler code here</font><br>              …<br>              }</span><br>            <p class="pt9-black"><br>            </p>          </td>        </tr>      </table>    </td>  </tr></table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -