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

📄 chapter9.htm

📁 这是一个学写JAVA的好东西
💻 HTM
📖 第 1 页 / 共 2 页
字号:
A.navigater:hover {	COLOR: #cc0000}.g1 {	FONT-SIZE: 14px}.g2 {	PADDING-LEFT: 21px; PADDING-TOP: 5px}.g3 {	FONT-WEIGHT: bold; COLOR: #ab6503}.g4 {	COLOR: #ff0000}.img {	BORDER-RIGHT: #800000 1px solid; BORDER-TOP: #800000 1px solid; BORDER-LEFT: #800000 1px solid; BORDER-BOTTOM: #800000 1px solid}.img1 {	BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid}.f14 {	FONT-SIZE: 14px; LINE-HEIGHT: 26px}.f20 {	FONT-WEIGHT: bold; FONT-SIZE: 20px}.top_red {	COLOR: #d70709; TEXT-DECORATION: none}.center01 {	COLOR: #000000; LINE-HEIGHT: 20px}.center01 TD {	COLOR: #000000; LINE-HEIGHT: 20px}.center01 A:link {	COLOR: #000000; TEXT-DECORATION: none}.center01 A:visited {	COLOR: #000000; TEXT-DECORATION: none}.center01 A:hover {	COLOR: #2b7128; TEXT-DECORATION: underline}.center02 {	COLOR: #194e00; LINE-HEIGHT: 20px}.center02 TD {	COLOR: #194e00; LINE-HEIGHT: 20px}.center02 A:link {	COLOR: #194e00; TEXT-DECORATION: none}.center02 A:visited {	COLOR: #194e00; TEXT-DECORATION: none}.center02 A:hover {	COLOR: #194e00; TEXT-DECORATION: underline}--></style><TABLE width=760 border=0 align=center cellPadding=0 cellSpacing=0 bgcolor="#F3F3F3" valign="top">	<tr class="center01"> 		<td width="488" style="padding-left:10px;padding-top:10px">			<a href="index.php">连载</a>       &gt; <a href="slist.php?class1=6">程序设计</a>      &gt; <a href="slist.php?class2=7">Java</a>      &gt; <a href="serialize.php?id=387">Java网络编程专辑</a>		</td>		<td width="280" style="padding-left:10px;padding-top:10px">			<div align="center">			<font color=#0000FF><a href='chapter.php?id=387&volume=1&chapter=9'>上一页</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<font color=#0000FF><a href="serialize.php?id=387">回书目</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<font color=#0000FF><a href='chapter.php?id=387&volume=1&chapter=11'>下一页</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			</div>		</td>	</tr>	<tr class="center01">		<td colspan="2" align="center" style="padding-left:10px;padding-top:10px">&nbsp;</td>	</tr>	<TBODY>	<TR> 		<TD colspan="2" align=middle>			<BR>			<div style="FONT-SIZE: 18pt; COLOR: #990000; FONT-FAMILY: 楷体_GB2312" align=center><B>基础知识</b></div><br><div style="COLOR: #990000; font-family: ; font-size: 18px;宋体;" align=center>Java网络编程之URI、URL研究(上4)</div>			<DIV style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE: 10.5pt; COLOR: black; LINE-HEIGHT: 180%" align=left>                         <br>&nbsp;&nbsp;&nbsp;&nbsp;<P><SPAN class=f14>URI类支持基本的URI操作,包括标准化(normalization)、分解(resolution)和相对化(relativization)。标准化是通过URI的normalize()方法支持的。调用normalize()时,它返回对新URI对象的引用,该对象包含调用的URI对象的URI的标准的表现。<BR><BR>  列表2演示了normalize()方法。它把URI作为程序的唯一的参数,URIDemo2打印出标准的相等的URI。<BR><BR>  列表2: URIDemo2.java<BR><BR></P>
<TABLE width="100%" bgColor=#ffffff>
<TBODY>
<TR>
<TD>// URIDemo2.java<BR><BR>import java.net.*;<BR><BR>class URIDemo2<BR>{<BR>public static void main (String [] args) throws Exception<BR>{<BR>if (args.length != 1)<BR>{<BR>System.err.println ("usage: java URIDemo2 uri");<BR>return;<BR>}<BR><BR>URI uri = new URI (args [0]);<BR><BR>System.out.println ("Normalized URI = " +<BR>uri.normalize ().toString ());<BR>}<BR>} </TD></TR></TBODY></TABLE><BR>  在编译URIDemo2后,在命令行输入java URIDemo2 x/y/../z/./q,将看到下面的输出:<BR><BR>Normalized URI = x/z/q<BR><BR>  上面的输出显示y、..和.消失了。这是因为..意味着你想直接在x下面访问名字空间的z部分,.意味着你希望访问与z部分相关的名字空间的q部分。<BR><BR>  URI通过提供resolve(String uri)、resolve(URI uri)和relativize(URI uri)方法支持反向解析和相对化操作。如果uri引用是空的(null)这三个方法都会产生NullPointerException对象。同样,如果指定的URI违反了RFC 2396语法规则,resolve(String uri)通过的内部的create(String uri)调用间接地产生一个IllegalArgumentException对象。<BR><BR>  列表3的代码演示了resolve(String uri)和relativize(URI uri)。<BR><BR>  列表3: URIDemo3.java<BR><BR>
<TABLE width="100%" bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD>// URIDemo3.java<BR><BR>import java.net.*;<BR><BR>class URIDemo3<BR>{<BR>public static void main (String [] args) throws Exception<BR>{<BR>if (args.length != 2)<BR>{<BR>System.err.println ("usage: " +<BR>"java URIDemo3 uriBase uriRelative");<BR>return;<BR>}<BR><BR>URI uriBase = new URI (args [0]);<BR>System.out.println ("Base URI = " +uriBase.toString ());<BR><BR>URI uriRelative = new URI (args [1]);<BR>System.out.println ("Relative URI = " +uriRelative.toString ());<BR><BR>URI uriResolved = uriBase.resolve (uriRelative);<BR>System.out.println ("Resolved URI = " +uriResolved.toString ());<BR><BR>URI uriRelativized = uriBase.relativize (uriResolved);<BR>System.out.println ("Relativized URI = " +uriRelativized.toString ());<BR>}<BR>}</TD></TR></TBODY></TABLE><BR>  在编译URIDemo3后,在命令行输入java URIDemo3 http://www.somedomain.com/ x/../y. ,输出如下:<BR><BR>
<TABLE width="100%" bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD>Base URI = http://www.somedomain.com/<BR>Relative URI = x/../y<BR>Resolved URI = http://www.somedomain.com/y<BR>Relativized URI = y</TD></TR></TBODY></TABLE><BR>  上面的输出显示相对的URI的x/../y根据基础URI http://www.somedomain.com/分解并(在内部)标准化,取得了已分解的http://www.somedomain.com/URI。给定该URI和基础URI,该已分解的URI根据基础URI相对化获得了y,它是原始的但是标准的相对的URI。<BR><BR>  <B>技巧</B><BR><BR>  调用URI的toURL()方法把URI转换为URL。<BR><BR>  在本周日的专题中我将向读者介绍如何使用URL以及MIME(多用途的网际邮件扩充协议)的概念以及它如何与URL发生联系,敬请期待。</SPAN><br><br>          </DIV>		</TD>	</TR>	<TR> 		<TD class=center01>			<div align="center">来源:天极网 作者:<div>		</TD>		<TD width="280" class=center01>			<div align="center">			<font color=#0000FF><a href='chapter.php?id=387&volume=1&chapter=9'>上一页</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<font color=#0000FF><a href="serialize.php?id=387">回书目</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			<font color=#0000FF><a href='chapter.php?id=387&volume=1&chapter=11'>下一页</a></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;			</div>		</TD>	</TR>	</TBODY></TABLE><table><tr><td width="760"> <table width="760" height="10" border="0" cellpadding="0" cellspacing="0">                        <tr>                                <td></td>                        </tr>                </table>                <!------------ 评论 ---------------->                <table width="760" border="0" cellpadding="0" cellspacing="0">                        <tr>                                <td><iframe width="100%" id=vs frameborder=0 scrolling=no src="comment_list1.php?id=387"></iframe>                                </td>                        </tr>                </table><br><script language=javascript>function CheckNetwordForm(theForm){        if("" == theForm.content.value)        {                alert("写两句吧~~");                theForm.content.focus();                return false;        }        var index;        for(index=0;index<theForm.content.value.length;index++)        {                if(" " != theForm.content.value.charAt(index))                        break;        }        if(index == theForm.content.value.length) {                alert("写两句吧~~");                theForm.content.focus();                return false;        }        if (theForm.content.value.length>100){                alert("评论字数不能超过100哦");                theForm.content.focus();                return false;        }        return true;}</script>                <!------------------ 评论 --------------->                <form name=netword method=post action="insertnetword.php" onsubmit="javascript: return CheckNetwordForm(this);">                <table width="760" border="0" cellpadding="0" cellspacing="0">                        <tr>                                <td height="25" class="text6">&nbsp;给此书打分:<a name="1"></a>                                        <select name="score">                                                <option value=5 selected>非常好</option>                                                <option value=4>还凑合</option>                                                <option value=3>一般吧</option>                                                <option value=2>不太行</option>                                                <option value=1>太差了</option>                                        </select> &nbsp; 用户名:                                        <input name="id" value=387 type="hidden" id="id">                                        <input name="backurl" value=/book/chapter.php?id=387&volume=1&chapter=10 type="hidden">                                        <input name="username" type="text" id="username" size="20" maxlength="20">                                        <font color="#666666">*评论字数请控制在一百字以内</font> </td>                        </tr>                </table>                <br>&nbsp;<textarea name="content" cols="80" rows="4" wrap="OFF" id="description"></textarea>                <input type="submit" name="Submit" value="提交">                </form>        </td> </tr></table></td></tr></table> <TABLE cellSpacing=0 cellPadding=0 width=760 border=0>  <TBODY>    <TR>       <TD width="1003" height=9 background=images/t_bj01.gif><IMG height=1     src="images/ccc.gif" width=1></TD>    </TR>  </TBODY></TABLE><TABLE cellSpacing=0 cellPadding=0 width=760 bgColor=#ffffff border=0>  <TBODY>    <TR>       <TD><HR width=760 noShade SIZE=1> </TD>    </TR>    <TR>       <TD align=middle><A class=black href="http://www.chinaren.com/"     target=_blank>ChinaRen</A> - <A class=black     href="http://big5.www.sohu.com/" target=_blank>繁体版</A> - <A class=black     href="http://hr.sohu.com/hrm.html" target=_blank>搜狐招聘</A> - <A class=black     href="http://add.sohu.com/" target=_blank>网站登录</A> - <A class=black     href="http://help.sohu.com/" target=_blank>帮助中心</A> - <A class=black     href="http://book.news.sohu.com/onClick=this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.sohu.com');return"     target=_blank false;>设置首页</A> - <A class=black     href="http://adinfo.sohu.com/" target=_blank>广告服务</A> - <A class=black     href="http://www.sohu.com/about/lianxi.htm" target=_blank>联系方式</A> - <A     class=black href="http://www.sohu.com/about/privacy.html"     target=_blank>保护隐私权</A> - <A class=black href="http://www.sohu.com/about/"     target=_blank>About SOHU</A> - <A class=black     href="http://www.sohu.com/about/" target=_blank>公司介绍</A><BR> <SPAN     class=eng>Copyright &copy; 2004 Sohu.com Inc. All rights reserved. 搜狐公司         版权所有</SPAN> </TD>    </TR>  </TBODY></TABLE></center></body></html><script language="JavaScript" src="http://nielsen.js.sohu.com/nnselect.js"></script><noscript><img src='http://ping.nnselect.com/ping.gif?c=119' height='1' width='1'></noscript>

⌨️ 快捷键说明

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