??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产欧美一区,精品久久视频,中文字幕欧美日韩一区二区三区http://www.aygfsteel.com/jorwen/category/7238.htmlzh-cnWed, 28 Feb 2007 11:49:35 GMTWed, 28 Feb 2007 11:49:35 GMT60一不错的讲解Java异常的文?/title><link>http://www.aygfsteel.com/jorwen/articles/29425.html</link><dc:creator>方佳?/dc:creator><author>方佳?/author><pubDate>Wed, 01 Feb 2006 04:36:00 GMT</pubDate><guid>http://www.aygfsteel.com/jorwen/articles/29425.html</guid><wfw:comment>http://www.aygfsteel.com/jorwen/comments/29425.html</wfw:comment><comments>http://www.aygfsteel.com/jorwen/articles/29425.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jorwen/comments/commentRss/29425.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jorwen/services/trackbacks/29425.html</trackback:ping><description><![CDATA[<SPAN id=ArticleContent1_ArticleContent1_lblContent> <P><FONT size=2>六种异常处理的陋?/FONT></P> <P><FONT size=2>你觉得自己是一个Java专家吗?是否肯定自己已经全面掌握了Java的异常处理机Ӟ在下面这D代码中Q你能够q速找出异常处理的六个问题吗?<BR><BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000"> OutputStreamWriter out </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> <IMG src="http://www.aygfsteel.com/images/dot.gif"> <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000"> java.sql.Connection conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> <IMG src="http://www.aygfsteel.com/images/dot.gif"> <BR><IMG id=Codehighlighter1_72_368_Open_Image onclick="this.style.display='none'; Codehighlighter1_72_368_Open_Text.style.display='none'; Codehighlighter1_72_368_Closed_Image.style.display='inline'; Codehighlighter1_72_368_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_72_368_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_72_368_Closed_Text.style.display='none'; Codehighlighter1_72_368_Open_Image.style.display='inline'; Codehighlighter1_72_368_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_72_368_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_72_368_Open_Text><SPAN style="COLOR: #000000">{ </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> ?nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">  Statement stat </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> conn.createStatement(); <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">  ResultSet rs </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> stat.executeQuery( <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">6</SPAN><SPAN style="COLOR: #000000">   </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">select uid, name from user</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">7</SPAN><SPAN style="COLOR: #000000">  </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (rs.next()) <BR><IMG id=Codehighlighter1_224_320_Open_Image onclick="this.style.display='none'; Codehighlighter1_224_320_Open_Text.style.display='none'; Codehighlighter1_224_320_Closed_Image.style.display='inline'; Codehighlighter1_224_320_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_224_320_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_224_320_Closed_Text.style.display='none'; Codehighlighter1_224_320_Open_Image.style.display='inline'; Codehighlighter1_224_320_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">8</SPAN><SPAN style="COLOR: #000000">  </SPAN><SPAN id=Codehighlighter1_224_320_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_224_320_Open_Text><SPAN style="COLOR: #000000">{ <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000">   out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">IDQ?/SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">uid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> ?nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Q姓名:(x)</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)); <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">11</SPAN><SPAN style="COLOR: #000000">  }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">12</SPAN><SPAN style="COLOR: #000000">  conn.close(); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> ?nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">13</SPAN><SPAN style="COLOR: #000000">  out.close(); <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">14</SPAN><SPAN style="COLOR: #000000"> }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">15</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(Exception ex) </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> ?nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_403_442_Open_Image onclick="this.style.display='none'; Codehighlighter1_403_442_Open_Text.style.display='none'; Codehighlighter1_403_442_Closed_Image.style.display='inline'; Codehighlighter1_403_442_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_403_442_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_403_442_Closed_Text.style.display='none'; Codehighlighter1_403_442_Open_Image.style.display='inline'; Codehighlighter1_403_442_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">16</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_403_442_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_403_442_Open_Text><SPAN style="COLOR: #000000">{ <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">17</SPAN><SPAN style="COLOR: #000000">  ex.printStackTrace(); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">_(d)?nbsp;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">18</SPAN><SPAN style="COLOR: #000000"> }</SPAN></SPAN></DIV></FONT></SPAN><BR><FONT size=2>作ؓ(f)一个JavaE序员,你至应该能够找Z个问题。但是,如果你不能找出全部六个问题,L(fng)l阅L文?<BR><BR>  本文讨论的不是Java异常处理的一般性原则,因ؓ(f)q些原则已经被大多数人熟知。我们要做的是分析各U可UCؓ(f)“反例”(anti-patternQ的q背优秀~码规范的常见坏?fn)惯Q帮助读者熟(zhn)这些典型的反面例子Q从而能够在实际工作中敏锐地察觉和避免这些问题?<BR><BR>  <B>反例之一Q丢弃异?</B><BR><BR>  代码Q?5?18行?<BR><BR>  q段代码捕获了异常却不作M处理Q可以算得上Java~程中的杀手。从问题出现的频J程度和害E度来看Q它也许可以和C/C++E序的一个恶名远播的问题相提q论??不检查缓冲区是否已满。如果你看到了这U丢弃(而不是抛出)异常的情况,可以癑ֈ之九(ji)十九(ji)地肯定代码存在问题(在极数情况下,q段代码有存在的理由Q但最好加上完整的注释Q以免引起别解)?<BR><BR>  q段代码的错误在于,异常Q几乎)L意味着某些事情不对劲了Q或者说臛_发生了某些不d的事情,我们不应该对E序发出的求救信号保持沉默和无动于衷。调用一下printStackTrace不上“处理异常”。不错,调用printStackTrace对调试程序有帮助Q但E序调试阶段l束之后QprintStackTrace׃应再在异常处理模块中担负主要责Q了?<BR><BR>  丢弃异常的情形非常普遍。打开JDK的ThreadDeathcȝ文档Q可以看C面这D说明:(x)“特别地Q虽然出现ThreadDeath是一U‘正常的情Ş’,但ThreadDeathcLError而不是Exception的子c,因ؓ(f)许多应用?x)捕h有的Exception然后丢弃它不再理睬。”这D话的意思是Q虽然ThreadDeath代表的是一U普通的问题Q但鉴于许多应用?x)试图捕h有异常然后不予以适当的处理,所以JDK把ThreadDeath定义成了Error的子c,因ؓ(f)ErrorcM表的是一般的应用不应该去捕获的严重问题。可见,丢弃异常q一坏习(fn)惯是如此常见Q它甚至已经影响CJava本n的设计?<BR><BR>  那么Q应该怎样Ҏ(gu)呢?主要有四个选择Q?<BR><BR>  1、处理异常。针对该异常采取一些行动,例如修正问题、提醒某个h或进行其他一些处理,要根据具体的情Ş定应该采取的动作。再ơ说明,调用printStackTrace不上已l“处理好了异常”?<BR><BR>  2、重新抛出异常。处理异常的代码在分析异怹后,认ؓ(f)自己不能处理它,重新抛出异常也不׃ؓ(f)一U选择?<BR><BR>  3、把该异常{换成另一U异常。大多数情况下,q是指把一个低U的异常转换成应用的异常(其含义更Ҏ(gu)被用户了解的异常Q?<BR><BR>  4、不要捕获异常?<BR><BR>  l论一Q既然捕获了异常Q就要对它进行适当的处理。不要捕获异怹后又把它丢弃Q不予理睬?<BR><BR>  <B>反例之二Q不指定具体的异?</B><BR><BR>  代码Q?5行?<BR><BR>  许多时候h们会(x)被这样一U“美妙的”想法吸引:(x)用一个catch语句捕获所有的异常。最常见的情形就是用catch(Exception ex)语句。但实际上,在绝大多数情况下Q这U做法不值得提倡。ؓ(f)什么呢Q?<BR><BR>  要理解其原因Q我们必d一下catch语句的用途。catch语句表示我们预期?x)出现某U异常,而且希望能够处理该异常。异常类的作用就是告诉Java~译器我们想要处理的是哪一U异常。由于绝大多数异帔R直接或间接从java.lang.ExceptionzQcatch(Exception ex)q当于说我们想要处理几乎所有的异常?<BR><BR>  再来看看前面的代码例子。我们真正想要捕L(fng)异常是什么呢Q最明显的一个是SQLExceptionQ这是JDBC操作中常见的异常。另一个可能的异常是IOExceptionQ因为它要操作OutputStreamWriter。显Ӟ在同一个catch块中处理q两U截然不同的异常是不合适的。如果用两个catch块分别捕获SQLException和IOExceptionp好多了。这是_(d)catch语句应当量指定具体的异常类型,而不应该指定늛范围太广的ExceptioncR?<BR><BR>  另一斚wQ除了这两个特定的异常,q有其他许多异常也可能出现。例如,如果׃某种原因QexecuteQueryq回了nullQ该怎么办?{案是让它们l箋抛出Q即不必捕获也不必处理。实际上Q我们不能也不应该去捕获可能出现的所有异常,E序的其他地方还有捕获异常的Z(x)??直至最后由JVM处理?<BR><BR>  l论二:(x)在catch语句中尽可能指定具体的异常类型,必要时用多个catch。不要试囑֤理所有可能出现的异常?<BR><BR>  <B>反例之三Q占用资源不释放 </B><BR><BR>  代码Q??14行?<BR><BR>  异常改变了程序正常的执行程。这个道理虽然简单,却常常被Z忽视。如果程序用C文g、Socket、JDBCq接之类的资源,即遇到了异常,也要正确释放占用的资源。ؓ(f)此,Java提供了一个简化这cL作的关键词finally?<BR><BR>  finally是样好东西:(x)不管是否出现了异常,Finally保证在try/catch/finally块结束之前,执行清理d的代码L有机?x)执行。遗憄是有些h却不?fn)惯使用finally?<BR><BR>  当然Q编写finally块应当多加小心,特别是要注意在finally块之内抛出的异常??q是执行清理d的最后机?x),量不要再有难以处理的错误?<BR><BR>  l论三:(x)保证所有资源都被正释放。充分运用finally关键词?/FONT> <P><FONT size=2><STRONG>反例之四Q不说明异常的详l信?<BR><BR></STRONG>  代码Q??18行?<BR><BR>  仔细观察q段代码Q如果@环内部出C异常Q会(x)发生什么事情?我们可以得到_的信息判断@环内部出错的原因吗?不能。我们只能知道当前正在处理的cd生了某种错误Q但却不能获得Q何信息判断导致当前错误的原因?<BR><BR>  printStackTrace的堆栈跟t功能显C出E序q行到当前类的执行流E,但只提供了一些最基本的信息,未能说明实际D错误的原因,同时也不易解诅R?<BR><BR>  因此Q在出现异常Ӟ最好能够提供一些文字信息,例如当前正在执行的类、方法和其他状态信息,包括以一U更适合阅读的方式整理和l织printStackTrace提供的信息?<BR><BR>  l论四:(x)在异常处理模块中提供适量的错误原因信息,l织错误信息使其易于理解和阅诅R?<BR><BR>  <B>反例之五Q过于庞大的try?</B><BR><BR>  代码Q??14行?<BR><BR>  l常可以看到有h把大量的代码攑օ单个try块,实际上这不是好习(fn)惯。这U现象之所以常见,原因在于有些h囄事,不愿花时间分析一大块代码中哪几行代码?x)抛出异常、异常的具体cd是什么。把大量的语句装入单个巨大的try块就象是出门旅游时把所有日常用品塞入一个大子Q虽然东西是带上了,但要扑և来可不容易?<BR><BR>  一些新手常常把大量的代码放入单个try块,然后再在catch语句中声明ExceptionQ而不是分d个可能出现异常的D落q分别捕获其异常。这U做法ؓ(f)分析E序抛出异常的原因带来了困难Q因Z大段代码中有太多的地方可能抛出Exception?<BR><BR>  l论五:(x)量减小try块的体积?<BR><BR>  <B>反例之六Q输出数据不完整</B> <BR><BR>  代码Q??11行?<BR><BR>  不完整的数据是JavaE序的隐形杀手。仔l观察这D代码,考虑一下如果@环的中间抛出了异常,?x)发生什么事情。@环的执行当然是要被打断的Q其ơ,catch块会(x)执行??p些,再也没有其他动作了。已l输出的数据怎么办?使用q些数据的h或设备将收到一份不完整的(因而也是错误的Q数据,却得不到M有关q䆾数据是否完整的提C。对于有些系l来_(d)数据不完整可能比pȝ停止q行带来更大的损失?<BR><BR>  较ؓ(f)理想的处|办法是向输备写一些信息,声明数据的不完整性;另一U可能有效的办法是,先缓冲要输出的数据,准备好全部数据之后再一ơ性输出?<BR><BR>  l论六:(x)全面考虑可能出现的异总?qing)这些异常对执行程的媄响?<BR><BR>  <B>改写后的代码</B> <BR><BR>  Ҏ(gu)上面的讨论,下面l出改写后的代码。也许有Z(x)说它E微有点?嗦,但是它有了比较完备的异常处理机制?<BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">OutputStreamWriter out </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> <IMG src="http://www.aygfsteel.com/images/dot.gif"> <BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>java.sql.Connection conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> <IMG src="http://www.aygfsteel.com/images/dot.gif"> <BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_66_288_Open_Image onclick="this.style.display='none'; Codehighlighter1_66_288_Open_Text.style.display='none'; Codehighlighter1_66_288_Closed_Image.style.display='inline'; Codehighlighter1_66_288_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_66_288_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_66_288_Closed_Text.style.display='none'; Codehighlighter1_66_288_Open_Image.style.display='inline'; Codehighlighter1_66_288_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_66_288_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_66_288_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> Statement stat </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> conn.createStatement(); <BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> ResultSet rs </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> stat.executeQuery( <BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">select uid, name from user</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (rs.next()) <BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_203_285_Open_Image onclick="this.style.display='none'; Codehighlighter1_203_285_Open_Text.style.display='none'; Codehighlighter1_203_285_Closed_Image.style.display='inline'; Codehighlighter1_203_285_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_203_285_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_203_285_Closed_Text.style.display='none'; Codehighlighter1_203_285_Open_Image.style.display='inline'; Codehighlighter1_203_285_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN id=Codehighlighter1_203_285_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_203_285_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">IDQ?/SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">uid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Q姓? </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)); <BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(SQLException sqlex) <BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_318_405_Open_Image onclick="this.style.display='none'; Codehighlighter1_318_405_Open_Text.style.display='none'; Codehighlighter1_318_405_Closed_Image.style.display='inline'; Codehighlighter1_318_405_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_318_405_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_318_405_Closed_Text.style.display='none'; Codehighlighter1_318_405_Open_Image.style.display='inline'; Codehighlighter1_318_405_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_318_405_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_318_405_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">警告Q数据不完整</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">); <BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> ApplicationException(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">d数据时出现SQL错误</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, sqlex); <BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(IOException ioex) <BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_433_491_Open_Image onclick="this.style.display='none'; Codehighlighter1_433_491_Open_Text.style.display='none'; Codehighlighter1_433_491_Closed_Image.style.display='inline'; Codehighlighter1_433_491_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_433_491_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_433_491_Closed_Text.style.display='none'; Codehighlighter1_433_491_Open_Image.style.display='inline'; Codehighlighter1_433_491_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_433_491_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_433_491_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> ApplicationException(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">写入数据时出现IO错误</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, ioex); <BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">finally</SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_503_877_Open_Image onclick="this.style.display='none'; Codehighlighter1_503_877_Open_Text.style.display='none'; Codehighlighter1_503_877_Closed_Image.style.display='inline'; Codehighlighter1_503_877_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_503_877_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_503_877_Closed_Text.style.display='none'; Codehighlighter1_503_877_Open_Image.style.display='inline'; Codehighlighter1_503_877_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_503_877_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_503_877_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_525_692_Open_Image onclick="this.style.display='none'; Codehighlighter1_525_692_Open_Text.style.display='none'; Codehighlighter1_525_692_Closed_Image.style.display='inline'; Codehighlighter1_525_692_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_525_692_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_525_692_Closed_Text.style.display='none'; Codehighlighter1_525_692_Open_Image.style.display='inline'; Codehighlighter1_525_692_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (conn </SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN id=Codehighlighter1_525_692_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_525_692_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_534_557_Open_Image onclick="this.style.display='none'; Codehighlighter1_534_557_Open_Text.style.display='none'; Codehighlighter1_534_557_Closed_Image.style.display='inline'; Codehighlighter1_534_557_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_534_557_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_534_557_Closed_Text.style.display='none'; Codehighlighter1_534_557_Open_Image.style.display='inline'; Codehighlighter1_534_557_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_534_557_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_534_557_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   conn.close(); <BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(SQLException sqlex2) <BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_592_688_Open_Image onclick="this.style.display='none'; Codehighlighter1_592_688_Open_Text.style.display='none'; Codehighlighter1_592_688_Closed_Image.style.display='inline'; Codehighlighter1_592_688_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_592_688_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_592_688_Closed_Text.style.display='none'; Codehighlighter1_592_688_Open_Image.style.display='inline'; Codehighlighter1_592_688_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_592_688_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_592_688_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   System.err(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.getClass().getName() </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.mymethod - 不能关闭数据库连? </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> sqlex2.toString()); <BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_714_874_Open_Image onclick="this.style.display='none'; Codehighlighter1_714_874_Open_Text.style.display='none'; Codehighlighter1_714_874_Closed_Image.style.display='inline'; Codehighlighter1_714_874_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_714_874_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_714_874_Closed_Text.style.display='none'; Codehighlighter1_714_874_Open_Image.style.display='inline'; Codehighlighter1_714_874_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (out </SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN id=Codehighlighter1_714_874_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_714_874_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_723_745_Open_Image onclick="this.style.display='none'; Codehighlighter1_723_745_Open_Text.style.display='none'; Codehighlighter1_723_745_Closed_Image.style.display='inline'; Codehighlighter1_723_745_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_723_745_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_723_745_Closed_Text.style.display='none'; Codehighlighter1_723_745_Open_Image.style.display='inline'; Codehighlighter1_723_745_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN id=Codehighlighter1_723_745_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_723_745_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   out.close(); <BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(IOException ioex2) <BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_778_870_Open_Image onclick="this.style.display='none'; Codehighlighter1_778_870_Open_Text.style.display='none'; Codehighlighter1_778_870_Closed_Image.style.display='inline'; Codehighlighter1_778_870_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_778_870_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_778_870_Closed_Text.style.display='none'; Codehighlighter1_778_870_Open_Image.style.display='inline'; Codehighlighter1_778_870_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_778_870_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_778_870_Open_Text><SPAN style="COLOR: #000000">{ <BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   System.err(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.getClass().getName() </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.mymethod - 不能关闭输出文g</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> ioex2.toString()); <BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top> }</SPAN></SPAN><SPAN style="COLOR: #000000"> <BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"> </SPAN></DIV></FONT><BR><FONT size=2>本文的结Z是放之四L(fng)准的教条Q有时常识和l验才是最好的老师。如果你对自q做法没有癑ֈ之百的信心,务必加上详细、全面的注释?<BR><BR>  另一斚wQ不要笑话这些错误,不妨问问你自己是否真地彻底摆׃q些坏习(fn)惯。即使最有经验的E序员偶?dng)也会(x)误入歧途,原因很简单,因ؓ(f)它们确实实带来了“方侎쀝。所有这些反例都可以看作Java~程世界的恶,它们丽动hQ无孔不入,时刻诱惑着你。也许有Z(x)认ؓ(f)q些都属于鸡皮蒜毛的事Q不x齿,但请CQ勿以恶而ؓ(f)之,勿以善小而不为?</FONT><BR><img src ="http://www.aygfsteel.com/jorwen/aggbug/29425.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jorwen/" target="_blank">方佳?/a> 2006-02-01 12:36 <a href="http://www.aygfsteel.com/jorwen/articles/29425.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java多线E设计模?/title><link>http://www.aygfsteel.com/jorwen/articles/29424.html</link><dc:creator>方佳?/dc:creator><author>方佳?/author><pubDate>Wed, 01 Feb 2006 04:34:00 GMT</pubDate><guid>http://www.aygfsteel.com/jorwen/articles/29424.html</guid><wfw:comment>http://www.aygfsteel.com/jorwen/comments/29424.html</wfw:comment><comments>http://www.aygfsteel.com/jorwen/articles/29424.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jorwen/comments/commentRss/29424.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jorwen/services/trackbacks/29424.html</trackback:ping><description><![CDATA[     摘要: java语言已经内置了多U程支持Q所有实现Runnable接口的类都可被启动一个新U程Q新U程?x)执行该实例的run()Ҏ(gu)Q当run()Ҏ(gu)执行完毕后,U程q束了。一旦一个线E执行完毕,q个实例׃能再重新启动Q只能重新生成一个新实例Q再启动一个新U程。ThreadcL实现了Runnable接口的一个实例,它代表一个线E的实例Qƈ且,启动U程的唯一Ҏ(gu)是通过Threadcȝstart()实例?..  <a href='http://www.aygfsteel.com/jorwen/articles/29424.html'>阅读全文</a><img src ="http://www.aygfsteel.com/jorwen/aggbug/29424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jorwen/" target="_blank">方佳?/a> 2006-02-01 12:34 <a href="http://www.aygfsteel.com/jorwen/articles/29424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>中文字符串长度计?/title><link>http://www.aygfsteel.com/jorwen/articles/29423.html</link><dc:creator>方佳?/dc:creator><author>方佳?/author><pubDate>Wed, 01 Feb 2006 04:30:00 GMT</pubDate><guid>http://www.aygfsteel.com/jorwen/articles/29423.html</guid><wfw:comment>http://www.aygfsteel.com/jorwen/comments/29423.html</wfw:comment><comments>http://www.aygfsteel.com/jorwen/articles/29423.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/jorwen/comments/commentRss/29423.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/jorwen/services/trackbacks/29423.html</trackback:ping><description><![CDATA[<P> </P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">  StringLengthTest<BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_31_228_Open_Image onclick="this.style.display='none'; Codehighlighter1_31_228_Open_Text.style.display='none'; Codehighlighter1_31_228_Closed_Image.style.display='inline'; Codehighlighter1_31_228_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_31_228_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_31_228_Closed_Text.style.display='none'; Codehighlighter1_31_228_Open_Image.style.display='inline'; Codehighlighter1_31_228_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_31_228_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_31_228_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) <BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_81_226_Open_Image onclick="this.style.display='none'; Codehighlighter1_81_226_Open_Text.style.display='none'; Codehighlighter1_81_226_Closed_Image.style.display='inline'; Codehighlighter1_81_226_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_81_226_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_81_226_Closed_Text.style.display='none'; Codehighlighter1_81_226_Open_Image.style.display='inline'; Codehighlighter1_81_226_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_81_226_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_81_226_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        String s </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">你好?/SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">length1: </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">s.length());<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        System.out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">length2: </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">s.getBytes().length);<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV> <P><BR>E:\>javac StringLengthTest.java<BR>E:\>java StringLengthTest</P> <P>length1: 3<BR>length2: 6<BR></P><img src ="http://www.aygfsteel.com/jorwen/aggbug/29423.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/jorwen/" target="_blank">方佳?/a> 2006-02-01 12:30 <a href="http://www.aygfsteel.com/jorwen/articles/29423.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ĵʡ</a>| <a href="http://" target="_blank">ֶ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¤</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ױ</a>| <a href="http://" target="_blank">Զ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ܱ</a>| <a href="http://" target="_blank">ʵ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">֬</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ƹ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˳ƽ</a>| <a href="http://" target="_blank">ǫ</a>| <a href="http://" target="_blank">Ѱ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">߮</a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>