﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-在Java里泡澡-随笔分类-Java</title><link>http://www.blogjava.net/rickqin/category/42279.html</link><description>~~苦啊~~</description><language>zh-cn</language><lastBuildDate>Wed, 21 Oct 2009 03:47:30 GMT</lastBuildDate><pubDate>Wed, 21 Oct 2009 03:47:30 GMT</pubDate><ttl>60</ttl><item><title>异常处理之六要注意</title><link>http://www.blogjava.net/rickqin/archive/2009/10/21/299166.html</link><dc:creator>Rick Qin</dc:creator><author>Rick Qin</author><pubDate>Wed, 21 Oct 2009 03:01:00 GMT</pubDate><guid>http://www.blogjava.net/rickqin/archive/2009/10/21/299166.html</guid><wfw:comment>http://www.blogjava.net/rickqin/comments/299166.html</wfw:comment><comments>http://www.blogjava.net/rickqin/archive/2009/10/21/299166.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/rickqin/comments/commentRss/299166.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/rickqin/services/trackbacks/299166.html</trackback:ping><description><![CDATA[
		<div id="blog_text" class="cnt">
				<p>
						<font face="Times New Roman">1、捕获了异常，就要对它进行适当的处理。不要捕获异常之后又把它丢弃，不予理睬。简单的printStackTrace不算处理；</font>
				</p>
				<p>
						<font face="Times New Roman">改正方案：<br />    a. 处理异常。针对该异常采取一些行动，例如修正问题、提醒某个人或进行其他一些处理，要根据具体的情形确定应该采取的动作。再次说明，调用printStackTrace算不上已经“处理好了异常”。<br />    b. 重新抛出异常。处理异常的代码在分析异常之后，认为自己不能处理它，重新抛出异常也不失为一种选择。<br />    c. 把该异常转换成另一种异常。大多数情况下，这是指把一个低级的异常转换成应用级的异常（其含义更容易被用户了解的异常）。<br />    d. 不要捕获异常。</font>
				</p>
				<p>
						<font face="Times New Roman">2、在catch语句中尽可能指定具体的异常类型，必要时使用多个catch。不要试图处理所有可能出现的异常。</font>
				</p>
				<p>
						<font face="Times New Roman">3、保证所有资源都被正确释放，充分运用finally关键字。</font>
				</p>
				<p>
						<font face="Times New Roman">4、在异常处理模块中提供适量的错误原因信息，组织错误信息使其易于理解和阅读。</font>
				</p>
				<p>
						<font face="Times New Roman">5、尽量减小try块的体积。</font>
				</p>
				<p>
						<font face="Times New Roman">6、全面考虑可能出现的异常以及这些异常对执行流程的影响。</font>
				</p>
		</div>
<img src ="http://www.blogjava.net/rickqin/aggbug/299166.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/rickqin/" target="_blank">Rick Qin</a> 2009-10-21 11:01 <a href="http://www.blogjava.net/rickqin/archive/2009/10/21/299166.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Java自带的Properties类访问配置文件</title><link>http://www.blogjava.net/rickqin/archive/2009/10/21/299163.html</link><dc:creator>Rick Qin</dc:creator><author>Rick Qin</author><pubDate>Wed, 21 Oct 2009 02:54:00 GMT</pubDate><guid>http://www.blogjava.net/rickqin/archive/2009/10/21/299163.html</guid><wfw:comment>http://www.blogjava.net/rickqin/comments/299163.html</wfw:comment><comments>http://www.blogjava.net/rickqin/archive/2009/10/21/299163.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/rickqin/comments/commentRss/299163.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/rickqin/services/trackbacks/299163.html</trackback:ping><description><![CDATA[
		<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<span style="color: rgb(0, 0, 0);">Properties props </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> Properties();<br />InputStream in </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> Main.</span>
				<span style="color: rgb(0, 0, 255);">class</span>
				<span style="color: rgb(0, 0, 0);">.getResourceAsStream(</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">p.properties</span>
				<span style="color: rgb(0, 0, 0);">"</span>
				<span style="color: rgb(0, 0, 0);">);  </span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);">p.properties文件与当前类同包</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">props.load(in);  </span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);">将配置文件内容加载到Properties对象中</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">BufferedReader input </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> </span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> BufferedReader(</span>
				<span style="color: rgb(0, 0, 255);">new</span>
				<span style="color: rgb(0, 0, 0);"> InputStreamReader(System.in));  </span>
				<span style="color: rgb(0, 128, 0);">//</span>
				<span style="color: rgb(0, 128, 0);">从屏幕接收用户输入</span>
				<span style="color: rgb(0, 128, 0);">
						<br />
				</span>
				<span style="color: rgb(0, 0, 0);">String key </span>
				<span style="color: rgb(0, 0, 0);">=</span>
				<span style="color: rgb(0, 0, 0);"> input.readLine();<br />System.out.println(props.get(key);</span>
		</div>
		<br />
<img src ="http://www.blogjava.net/rickqin/aggbug/299163.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/rickqin/" target="_blank">Rick Qin</a> 2009-10-21 10:54 <a href="http://www.blogjava.net/rickqin/archive/2009/10/21/299163.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>