<?xml version="1.0" encoding="GBK" ?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dcterms="http://purl.org/dc/terms/">
 <channel>
  	  <title><![CDATA[张若飞]]></title>
	  <link>http://tjligong.blog.163.com</link>
	  <description><![CDATA[人只有一直前进才有后退的余地。希望大家见证我们前进的每一步 ]]></description>
	  <language>zh-CN</language>
	  <pubDate>Tue, 23 Sep 2008 15:52:45 +0800</pubDate>
	  <lastBuildDate>Tue, 23 Sep 2008 15:52:45 +0800</lastBuildDate>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <generator><![CDATA[NetEase Space]]></generator>
	  <managingEditor><![CDATA[tjligong]]></managingEditor>
	  <webMaster><![CDATA[Alfred]]></webMaster>
		  <ttl>120</ttl>
	  <image>
	  	<title><![CDATA[张若飞]]></title>
	  	<url>http://ava.blog.163.com/photo/NK-EMmHui10zqUZ_ZMApfg==/2561703763043811572.jpg</url>
	  	<link>http://tjligong.blog.163.com</link>
	  </image>
  <item>
  	<title><![CDATA[中国人的一天]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200881722149726</link>
    <description><![CDATA[<div><P>都是同学发的，如下： </P>
<P>早上醒来，先用二甘醇超标的田七牙膏刷，再用发臭的 水洗脸，给儿子冲一瓶添加三聚氰胺的三鹿奶粉，自己杯黑作坊的豆浆，吃几个硫磺熏白了的馒头，或者是废纸箱当肉馅的包子，就点儿废旧油漆桶里腌的榨菜，包里放个安徽人05年的粽子（上班吃了吃），吃饱喝足，出门，深吸一口富含PX的空气，到断成两截的九江大桥上溜溜腿儿，找找白娘子和许相公在断桥的感觉。　　<BR>中午跟同事一起到肯德基吃顿苏丹红炸鸡，了杯苯超标的可乐。下午给朋友打电话，就听见她哭哭啼啼，大约是炒股炒赔地，约她出来到新开的菜馆吃顿地沟油炒的菜，来一盘避孕药催大的香辣鳝鱼，再来一盘臭水沟捞来的麻辣龙虾，还有个农药高残留的清炒菠菜，老板上一杯重金属超标100倍的碧螺春茶，再点含甲醛的啤酒……，算帐的时候168(太黑了，还不打折）吉利，老板又找回了一张假币。<BR>回家的时候被宝马撞倒，太幸运！得让丫出点血，所以躺着不动，一睁眼，看宝马调回头来碾压……以史无前例的速度爬起来跑掉。<BR>回家。要睡觉的时候，被刚装修完的赠品甲醛呛得眼泪直流，只好把脑袋蒙到黑心棉被子里。想起房子还有四十万贷款加利息，辗转反侧到天半亮都没眯。找安眠药吃了半瓶也没用，含在嘴里，哦，还好是糯米粉<BR></P>
<P>还有一个</P>
<P>一个中国人幸福的一天！ 早晨起床，掀开黑心绵作的被子，用致癌牙膏刷完牙，喝杯过了期的碘超标还掺了三聚氰胺的牛奶，吃根柴油炸的洗衣粉油条，外加一个苏丹红咸蛋，在票贩子手里买张车票，准时赶到地下烟厂上班，九点三十分偷偷用山寨手机看股票从6124.04点跌到1240.46点，中午在餐馆点一盘用地沟油炒的避孕药喂的黄膳，再加一碟敌敌畏喷过的白菜，盛两碗杯陈化粮煮的毒米饭；晚上蒸一盘病的瘦肉精养大的死猪肉做的腊肉，沾上点毛发勾兑的毒酱油，夹两片大粪水浸泡的臭豆腐，还有用福尔马林泡过的凉拌海蜇皮，抓两个添加了漂白粉和吊白块的大馒头，还喝上两杯富含甲醇的白酒。唉……这日子过的真是那个爽!!!这就是一个中国人幸福的一天 </P>
<P>&nbsp;</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200881722149726</comments>
    <slash:comments>6</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200881722149726</guid>
    <pubDate>Wed, 17 Sep 2008 14:21:49 +0800</pubDate>
    <dcterms:modified>2008-09-17T14:21:49+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[地震照片定格伟大母爱 战士讲述幕后故事]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/2744844820088384118907</link>
    <description><![CDATA[<div><DIV>&nbsp;</DIV>
<DIV>
<DIV>
<DIV>地震照片定格伟大母爱 战士讲述幕后故事</DIV>
<DIV>
<DIV>
<DIV><IMG height=378 src="http://img1.qq.com/news/pics/12686/12686066.jpg" width=500 border=0> </DIV></DIV>
<DIV>
<P>8月31日上午，消防官兵从会理县黎溪镇新桥村废墟中挖出两名群众遗体。新华社发(邹森 摄)</P>
<P><STRONG>攀枝花6.1级地震追踪</STRONG></P>
<P><STRONG>令人流泪照片 定格伟大母爱</STRONG></P>
<P><STRONG>照片中的4位消防战士讲述照片幕后故事</STRONG></P>
<P>正在吃饭的母亲，在地震袭来的瞬间，用自己的身体护住了一旁的女儿，连手中的筷子都没来得及丢掉。无情的地震夺走了母女俩的生命，但当消防官兵把她们从废墟中刨出来时，她们僵硬的身体依旧保持着紧紧相拥的姿势，在死亡的最后一刻，母亲依旧保护着她的女儿……</P>
<P>这是“8·30”攀枝花地震中，发生在凉山州会理县黎溪镇新桥村的真实一幕。这一幕被定格成照片，出现在各大媒体显要位置，令不少人为之感动泪流。作为当时的见证者，昨（2）日，照片上正在刨母女俩遗体的4位西昌消防中队战士向记者讲述了照片背后的故事。</P>
<P><B>求救</B></P>
<P><B>母子三人被埋废墟</B></P>
<P>“我老婆和两个娃娃都遭压在房子下头了！”8月31日凌晨2时许，西昌市消防中队40多名队员刚刚赶到会理县黎溪镇新桥村，就遇到一中年男子求救。该男子称地震发生时，自己妻子和15岁的儿子、9岁的女儿正在吃饭，结果不幸被垮塌的房子掩埋。由于该男子是在外打工刚回来，并不清楚自己一家三口所处的具体位置，因此救援队员只得凭“吃饭”这一线索，将厨房、堂屋两地作为突击搜救点，实施救援。</P>
<P>由于该男子一家居住的是土坯房，垮塌后已变成一堆红土，根本分不出原有结构，因此厨房、堂屋的准确位置无法正确辨认，一连五六个小时的搜救没有任何进展。不得已，大家只得从废墟边上开始，展开地毯式搜索，一点一点地掘进。不久，救援人员在堂屋找到了被埋的15岁少年。他是中年男子的儿子，已经死亡。</P>
<P><B>救援</B></P>
<P><B>战士不忍查看生死</B></P>
<P>“没找到的时候着急，找到了又害怕她们已经遇难……”</P>
<P>一把红色的梳子，静静地躺在已松散的夯土中；梳子旁边，露出几缕头发，长时间的深度掩埋，发丝已变得毛糙、枯黄。</P>
<P>31日上午10时许，在废墟下一米多深的地方，救援人员发现了这样的场景，8个多小时的搜救终于又有了进展。所有救援人员都非常激动，文伟和薛红兵、钟银、刘小威四个在最前线的战士更是用出了吃奶的劲儿，加紧挖掘。但随着周围夯土一点一点被刨开，4个人心里却越来越不安了，“没找到的时候着急，找到了又害怕她们已经遇难……”结果，当被困者头部露出来时，4个人竟然都不约而同地迟疑了，“没人忍心去查看她们的生死。”</P>
<P>这次找到的被困者是求救男子的妻子，已经死亡。文伟等4人心情沉重地继续挖掘，却发现了一个“奇特”的姿势：这位中年妇女面部朝下，背部上拱，双手呈拥抱状，右手还握着筷子。</P>
<P><B>震撼</B></P>
<P><B>母亲至死紧护女儿</B></P>
<P>“干了这么多年救援，就从没见过这样的场面。”</P>
<P>“下面肯定还有人！”薛红兵大叫起来，“汶川大地震的时候，这样的情况很多！”</P>
<P>果然，当薛红兵等徒手往下刨出10多厘米后，又一具遗体露出来，她正是遇难者9岁的女儿。这时，救援现场的人们都因巨大的感动而沉默了——当地震来临时，母亲将女儿紧紧地拥在自己怀里，身体下伏、背部上拱，用自己的身体挡着不断掉落的夯土、瓦片、木头等杂物，拼命想护住自己的女儿。她反应之敏捷、动作之迅速，以至于忘了丢下自己手中的筷子……</P>
<P>求救的男子扑通一声跪倒在地，泪水瞬间打湿了面颊；协助救援的村民们也都纷纷捂着脸，退向外围；文伟、薛红兵、钟银和刘小威低下头，悄悄抹去眼泪，“干了这么多年救援，就从没见过这样的场面。”为了不伤害母女俩的遗体，4个人把锄头、铁锹等全部扔了出去，改为徒手挖掘，“每一秒钟，我都有一种想跪倒的感觉，我们所面对的，已不是她们的遗体，而是伟大的母爱。”</P>
<P><B>定格</B></P>
<P><B>感人记忆永生难忘</B></P>
<P>“这个画面一辈子也不会忘记的！”</P>
<P>母女俩被完全刨出来时，依然保持着紧紧相拥的姿势。救援官兵们对她们实施了分离，但因为她们抱得太紧，分离花了差不多20分钟，而即便是完成分离后，这位母亲依旧保持着拥抱的姿势。</P>
<P>4名战士将母女俩遗体抱离现场后，又回废墟停留了10多分钟。大家坐在发现母女俩的地方，相顾无言，而就在这里，文伟给母亲发了一条报平安的短信。他们商量着，要把战友、媒体抓拍下来的照片永久珍藏，照片中间，是至死相拥的母女；两边，则是他们徒手挖刨的身影，“这个画面一辈子也不会忘记的！伟大的母亲，伟大的母爱！”</P>
<P>早报记者 王晶城 实习生 耿姝</P>
<P>&nbsp;</P></DIV></DIV></DIV></DIV><BR><BR><BR>引文来源&nbsp;&nbsp;<A href="http://news.qq.com/a/20080903/000455.htm" target=_blank>地震照片定格伟大母爱 战士讲述幕后故事_国内图片_新闻_腾讯网</A></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/2744844820088384118907</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/2744844820088384118907</guid>
    <pubDate>Wed, 3 Sep 2008 08:41:18 +0800</pubDate>
    <dcterms:modified>2008-09-03T08:41:18+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Java中用LinkedList实现Stack]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/274484482008814545947</link>
    <description><![CDATA[<div><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=3>Java中自带了Stack类，但是其父类为Vector，这恰恰是最不应该的。因为Vector的底层为数组，且Vector拥有get方法（意味着它可能访问到并不属于最后一个位置元素的其他元素，很不安全）（摘自</FONT><A href="http://www.blogjava.net/bounce/archive/2007/03/19/104831.html"><FONT size=3>http://www.blogjava.net/bounce/archive/2007/03/19/104831.html</FONT></A><FONT size=3>）。因此实现Stack的最佳方式是使用LinkedList，并且不要提供能够让不是最后一个元素的元素出栈的方法。</FONT></P>
<P>import java.util.LinkedList;</P>
<P>class Stack {<BR>&nbsp;LinkedList ll = new LinkedList();</P>
<P>&nbsp;public void push(Object o) {<BR>&nbsp;&nbsp;ll.addFirst(o);<BR>&nbsp;}</P>
<P>&nbsp;public Object pop() {<BR>&nbsp;&nbsp;return ll.removeFirst();<BR>&nbsp;}</P>
<P>&nbsp;public Object peek() {<BR>&nbsp;&nbsp;return ll.getFirst();<BR>&nbsp;}</P>
<P>&nbsp;public boolean empty() {<BR>&nbsp;&nbsp;return ll.isEmpty();<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;public int size() {<BR>&nbsp;&nbsp;return ll.size();<BR>&nbsp;}</P>
<P>&nbsp;public static void main(String[] args) {<BR>&nbsp;&nbsp;Stack ms = new Stack();<BR>&nbsp;&nbsp;ms.push("a");<BR>&nbsp;&nbsp;ms.push("b");<BR>&nbsp;&nbsp;ms.push("c");<BR>&nbsp;&nbsp;System.out.println(ms.size());</P>
<P>&nbsp;&nbsp;System.out.println(ms.pop());<BR>&nbsp;&nbsp;System.out.println(ms.size());<BR>&nbsp;&nbsp;System.out.println(ms.empty());<BR>&nbsp;}<BR>}<BR></P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/274484482008814545947</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/274484482008814545947</guid>
    <pubDate>Mon, 1 Sep 2008 16:54:05 +0800</pubDate>
    <dcterms:modified>2008-09-01T16:59:22+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[痛苦的捂住脸扭向一边系列【MOP】]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200872555515754</link>
    <description><![CDATA[<div><P>最近颇受打击，YY买了房，188平的，无语。。。</P>
<P>看大家过的都不错，工资高，奖金高，工作轻松，而我却还为了那可怜的工资没日没夜的加班，心里的酸楚只有自己知啊。。</P>
<P>下面从MOP看到的，聊以自嘲吧</P>
<P>&nbsp;</P>
<P>去年公司来一Ａｓｓｉｓｔａｎｔ,女,刚满30,外貌平平<BR>一日说一起出去k歌　正讨论哪几个一起打的拼车　那女说,我带你们去下楼，porsche<BR>随问：自己买的？<BR>答：偶男人的求婚礼物　年底偶们结婚 他看我家开的是porsche　就买了同一系列的送偶<BR>问：你男人和你住一起？<BR>答：还没 他在我家别墅对面买了一栋 现在和我们是门对门的<BR>恍然大悟：什么叫门当户对~~</P>
<P>继续：你还来工作干嘛？<BR>答：每天蹦迪泡把也没意思啊<BR>ORZ~~~~</P>
<P>婚后3个月后此女怀孕 立马炒了sap鱿鱼 从此偶在公司再也米有看到过<BR>porsche............</P>
<P><BR>痛苦的捂住脸扭向一边系列<BR>--------------------------------------------------------------------------------</P>
<P><BR>朋友在某地移动上班，这天来了个新同事，跟他一样都是业务员，工资1300<BR>第一天，朋友带他跑业务，开公司的面包车<BR>这位仁兄见了面包车直摇头，"这车空调太弱，会很热的，干脆坐我的车"<BR>朋友："哟？你开了车来上班的嗦？车在哪呢？"<BR>他：（抬头、努嘴）"呐，那辆黑色的"<BR>奔驰S600<BR>朋友痛苦的捂住脸扭向一边<BR>后来他们经理看不下去了，觉得这样会影响团结。就把他叫去谈话。<BR>经理："你能不能低调一点？在这很多人都是走关系进来的，但是大家都很低调，你不要搞特殊化嘛"<BR>他："恩恩恩"（相当的诚恳）<BR>于是第二天<BR>银灰色宝马<BR>经理觉得输人不能输气势，又把他叫去谈话<BR>"你能不能再低调一点？"<BR>"恩恩恩"（相当的诚恳）<BR>第三天<BR>凯美瑞<BR>经理痛苦的捂住脸扭向一边<BR>朋友就很好奇啊，问他，"你条件这么好，为啥还来我们这公司上班喃？杂不直接跟着父母做生意哦？"</P>
<P><BR>你们猜杂回答的？</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>"我不想依靠父母"</P>
<P>--------------------------------------------------------------------------------</P>
<P><BR>去年公司来一QC,女的,30出头,外貌平平<BR>第一天,总经理喊副科,带她去工厂看看,熟悉一下(去工厂全是坐公交的)<BR>那女的说,在哪边的？我带你们去下楼，凯美瑞2.4<BR>我们总经理才凯美瑞1.8<BR>第2天，公司说给她配个电脑，她说不用了，从包里掏出一notebook<BR>下午，经理喊她进去，你走吧，你比我有钱....然后痛苦的捂住脸扭向一边<BR>她走前我们问她，你这样还来上班做啥？<BR>她说，老公是工厂老总，每天太忙，没人陪她，只好自己出来找点事儿做<BR>--------------------------------------------------------------------------------</P>
<P><BR>前几个月单位招了个些新人,分配到楼下的网点了,刚好是季度末,要算存款额的,负责人希望下面的人大力一些拉存款.结果第二天一妇女来那新人那做了个750w的7天通知存款. 一些老员工问这女孩啥能耐.<BR>"没有,那是我妈,昨晚跟她说过一下,她说今天从信用社那边划些钱过来帮我做做绩效任务囖."<BR>--------------------------------------------------------------------------------</P>
<P><BR>上班遇到的第一个同事，跟我一样住宿舍、吃食堂、骑自行车上下班，甚至手提电脑都没有。。。超级低调的一个女生，用钱也是精打细算的。</P>
<P>后来才知道，她家有一架直升飞机。。。<BR>--------------------------------------------------------------------------------</P>
<P><BR>我朋友的女朋友是某房地产大亨的千金，曾经在某投资公司打工，小职员。然则干了2-3个月后对这公司产生感情，第二天变成公司股东了。。<BR>--------------------------------------------------------------------------------</P>
<P><BR>朋友工作的某银行新进一海龟女生，职务普通业务，开锐志上班，亲爹是财厅某把手。一日行长为某政策问题焦头烂额上蹿下跳，只见该女生施施然拿出手机拨通电话："喂，陈叔叔啊，好久不见，我爸？挺好的。我吗，前几个月回来，现在在X行上班。有件事拜托你，blablabla...什么，你来找我？不用不用……"……<BR>相关链接: 行长自然也是痛苦的捂住脸扭向一边<BR>--------------------------------------------------------------------------------</P>
<P><BR>面试过一个开着别克君威来的，应聘Designer, 25岁。简历里直接写，希望公司提供停车位<BR>--------------------------------------------------------------------------------</P>
<P><BR>我也讲一个，我大学有个同学每天拿个那个2升的可乐瓶子灌满开水，背个书包那种登山那种装的满满的（都是书，不管每天有几节课），每顿饭几乎都是4个馒头5毛的素菜，后来听说他爹是湖南省林业厅厅长，他爷爷曾和zm.j同事过</P>
<P><BR>大学舍友..相当低调的一女生..每个月只用500多的生活费..长得挺漂亮..大二放假去她家玩才知道..她家企业进福清10强..北京上海深圳都有别墅...T.T~~还跟我说以后去那些城市玩可以住她家..反正她家平常没人住..只有保姆看着房子...我和几个舍友当场被雷.. </P>
<P>------------------------------------------------------------------------------------------</P>
<P><BR>之前在某银行做的时候..见行长天天坐着a8 3.2出门,觉得这行福利真好啊~~~后来跟个同事混熟了..才知道那是他家的车T.T...无语..因为行长的配车是太差..就征用他的车了..1个月后,我那同事忍无可忍..说那车加了油都行长在开..又没给抱邮费..觉得非常不爽...跟我抱怨的下个星期一开了辆凯美瑞来..说:怎样..刚买的!绿色!你看这车牌(*9138)!行长肯定不找我要车开了~~....之前很疑惑的问过他为什么不接他爸生意..他的回答也是:不想靠父母..听了我都愤怒..PS..他家在我们福州机场10分钟的车程买了个山头..盖了个...类似庭院类似别墅..还有小桥流水的..房子..专门渡假.... </P>
<P>--------------------------------------------------------------------------</P>
<P>也说个我们系统的。。 <BR>某男，公务员，年仅20，刚上班时开了辆大红的bmw,跑车，z4 <BR>后来被局长找去谈话，说公务员要低调，大男人不要开红色的车，然后他第二天开了辆白的bmw，5系 <BR>又被局长找去谈话，说最好不要开宝马来上班，这小子立马去雪弗兰订了一辆spark，过了几天开了辆spark上班，中间这段时间倒是没开宝马，开了辆雅阁，自此没再被领导找过。。。。。 </P>
<P>--------------------------------------------------------------------------</P>
<P><BR>我以前一同事也极BH，我当时做事的是个小杂志，她在里面做广告业务，工资挺低，平时穿着打扮也不怎么样，人倒是很好，后来和她熟了，才知道她家超有米，开工厂的，还是那种家族企业，挺大的，然后每次出去跑业务，就是先自己开着摩托车去，然后到一个地方等她老公开车来接，说是不想太张扬，不过后来估计做得觉得没意思了，就开始很BH的懒散了，经常就不来上班，有次我们主编看她没来，实在忍不住，就打电话给她问她怎么回事，她答得巨BH，说：昨天晚上老公回来晚了，然后我们ML了，结果今天没力气爬起来，所以请假吧~~——全公司的人都被雷昏了！！！！&nbsp; 反正她来公司就是消遣，工资被扣光了她也不在乎，每次来就是为了找几个人陪她一起出去逛街然后大吃大喝~~~记得后来她叫我们去她家玩，我有事没去，另一个去了的同事说吓死了，说从她家大门到进屋开车开了15分钟，娘的……</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200872555515754</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200872555515754</guid>
    <pubDate>Mon, 25 Aug 2008 17:55:15 +0800</pubDate>
    <dcterms:modified>2008-08-25T17:55:50+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Grails配Acegi插件时两点注意]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200872110201126</link>
    <description><![CDATA[<div><P>1.由于我用的是JDK1.6，自带了jce.jar，这样会与插件产生冲突，报如下错</P>
<P>association.Association Unsupported algorithm: HmacSHA1, size: 160<BR>java.security.NoSuchAlgorithmException: HmacSHA1 KeyGenerator not available</P>
<P>在library中将JDK中的该包去掉就可以了，不过好像不除去也不影响插件的使用。。。</P>
<P>2.在建好Acegi的Role后（参见<A href="http://www.grails.org/AcegiSecurity+Plugin+-+Basic+Tutorial">http://www.grails.org/AcegiSecurity+Plugin+-+Basic+Tutorial</A>），用user注册时会提示找不到默认的Role，这是因为在securityCofing.groovy中指定了</P>
<P>defaultRole = 'ROLE_USER'</P>
<P>而在Role.groovy中我们可以看见</P>
<P>String authority = 'ROLE_'</P>
<P>所以只要在RoleController中新建一个角色user，记住不是ROLE_USER，这样就可以在usercontroller中注册了。</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200872110201126</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200872110201126</guid>
    <pubDate>Thu, 21 Aug 2008 22:20:11 +0800</pubDate>
    <dcterms:modified>2008-08-22T03:23:31+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Java超牛面试]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/274484482008716101547135</link>
    <description><![CDATA[<div><DIV>
<DIV>
<P>&nbsp;</P></DIV>
<DIV>
<DIV>
<H2>Java超牛面试</H2>
<P>Submitted by <STRONG>精灵</STRONG> on 2008, June 8, 1:34 PM. 其它</P>
<DIV>
<P>面试官：熟悉哪种语言 <BR>　　应聘者：Java。 <BR>　　面试官：知道什么叫类么 <BR>　　应聘者：我这人实在，工作努力，不知道什么叫累 <BR>　　面试官：知道什么是包? <BR>　　应聘者：我这人实在 平常不带包 也不用公司准备了 <BR>　　面试官：知道什么是接口吗? <BR>　　应聘者：我这个人工作认真。从来不找借口偷懒 <BR>　　M：知道什么是继承么 <BR>　　Y：我是孤儿没什么可以继承的 <BR>　　M:知道什么叫对象么？ <BR>　　M:知道，不过我工作努力，上进心强，暂时还没有打算找对象。 <BR>　　M：知道多态么？ <BR>　　Y：知道，我很保守的。我认为让心爱的女人为了自已一时的快乐去堕胎是不道德的行为！ <BR>　　请问这和Java有什么关系？？ <BR>　　面试官：用过 apache 的东西吗 <BR>　　应聘者：我修过车子 <BR>　　M：tomcat了解么 <BR>　　Y：小时看过。。现在也喜欢看 <BR>　　面试官：了解webwork吗 <BR>　　应聘者：不了解。我一直专注于本职工作，对外部的没有时间涉猎。 <BR>　　M:了解jakarta的哪些项目？ <BR>　　Y:不了解，我只去那儿旅游过。 <BR>　　M:用过bea的weblogic吗？ <BR>　　Y:没，只喝过蜂蜜。 <BR>　　M:了解SUN的创始人吗？ <BR>　　Y:不知道，不过我爆喜欢队中的纳什 <BR>　　M：用过spring么？ <BR>　　Y：没用过，发过。 <BR>　　M：知道Hibernate吗 <BR>　　Y：知道，动物冬天经常Hibernate,但我从来不冬眠 <BR>　　M：知道css吗? <BR>　　Y：cs出加强版了？ <BR>　　M：OCR用作过没？ <BR>　　Y：我从不玩魔兽 <BR>　　M：W3C标准常用什么地方 <BR>　　Y：Lost Tample <BR>　　M：知道REST么？ <BR>　　Y：我很勤奋，只知道干活，不知道休息。</P></DIV>
<H2>&nbsp;</H2></DIV></DIV></DIV><BR><BR><BR>引文来源&nbsp;&nbsp;<A href="http://www.fuckhacker.net/?action=show&amp;id=218" target=_blank>Java超牛面试</A><p>----------------------------<br/>一键转贴，快速捕捉生活精彩，赢每周好礼！<a href="http://blog.163.com/activities/hunter/hunter.do?080526jclr46" target="_blank">查看活动首页&gt;&gt;</a></p></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/274484482008716101547135</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/274484482008716101547135</guid>
    <pubDate>Sat, 16 Aug 2008 10:15:47 +0800</pubDate>
    <dcterms:modified>2008-08-16T10:15:47+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[(转贴)Runtime.exec()的陷阱]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200871112950108</link>
    <description><![CDATA[<div><P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em">When Runtime.exec() won't </P>
<P style="TEXT-INDENT: 2em">Navigate yourself around pitfalls related to the Runtime.exec() method Summary</P>
<P style="TEXT-INDENT: 2em">In this installment of Java Traps, Michael Daconta discusses one new pitfall and revisits another from his previous column. Originating in the java.lang package, the pitfall specifically involves problems with the Runtime.exec() method. Daconta also corrects an error from Pitfall 3 and offers a simpler solution. (2,500 words) </P>
<P style="TEXT-INDENT: 2em">s part of the Java language, the java.lang package is implicitly imported into every Java program. This package's pitfalls surface often, affecting most programmers. This month, I'll discuss the traps lurking in the Runtime.exec() method. </P>
<P style="TEXT-INDENT: 2em">Pitfall 4: When Runtime.exec() won't </P>
<P style="TEXT-INDENT: 2em">The class java.lang.Runtime features a static method called getRuntime(), which retrieves the current Java Runtime Environment.</P>
<P style="TEXT-INDENT: 2em">That is the only way to obtain a reference to the Runtime object. With that reference, you can run external programs by invoking the Runtime class's exec() method. Developers often call this method to launch a browser for displaying a help page in HTML. </P>
<P style="TEXT-INDENT: 2em">There are four overloaded versions of the exec() command: public Process exec(String command); public Process exec(String [] cmdArray); public Process exec(String command, String [] envp); public Process exec(String [] cmdArray, String [] envp); </P>
<P style="TEXT-INDENT: 2em">For each of these methods, a command -- and possibly a set of arguments -- is passed to an operating-system-specific function call. This subsequently creates an operating-system-specific process (a running program) with a reference to a Process class returned to the Java VM. The Process class is an abstract class, because a specific subclass of Process exists for each operating system. </P>
<P style="TEXT-INDENT: 2em">You can pass three possible input parameters into these methods: A single string that represents both the program to execute and any arguments to that program An array of strings that separate the program from its arguments </P>
<P style="TEXT-INDENT: 2em">Pass in the environment variables in the form If you use the version of exec() with a single string for both the program and its arguments, note that the string is parsed using white space as the delimiter via the StringTokenizer class. </P>
<P style="TEXT-INDENT: 2em">Stumbling into an IllegalThreadStateException </P>
<P style="TEXT-INDENT: 2em">The first pitfall relating to Runtime.exec() is the IllegalThreadStateException. The prevalent first test of an API is to code its most obvious methods. For example, to execute a process that is external to the Java VM, we use the exec() method. To see the value that the external process returns, we use the exitValue() method on the Process class. In our first example, we will attempt to execute the Java compiler (javac.exe): </P>
<P style="TEXT-INDENT: 2em">Listing 4.1 BadExecJavac.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">public class BadExecJavac</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("javac");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.exitValue();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Process exitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">A run of BadExecJavac produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java BadExecJavac</P>
<P style="TEXT-INDENT: 2em">java.lang.IllegalThreadStateException: process has not exited</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Win32Process.exitValue(Native Method)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at BadExecJavac.main(BadExecJavac.java:13)</P>
<P style="TEXT-INDENT: 2em">If an external process has not yet completed, the exitValue() method will throw an IllegalThreadStateException; that's why this program failed. While the documentation states this fact, why can't this method wait until it can give a valid answer? </P>
<P style="TEXT-INDENT: 2em">A more thorough look at the methods available in the Process class reveals a waitFor() method that does precisely that. In fact, waitFor() also returns the exit value, which means that you would not use exitValue() and waitFor() in conjunction with each other, but rather would choose one or the other. The only possible time you would use exitValue() instead of waitFor() would be when you don't want your program to block waiting on an external process that may never complete. Instead of using the waitFor() method, I would prefer passing a boolean parameter called waitFor into the exitValue() method to determine whether or not the current thread should wait. A boolean would be more beneficial because exitValue() is a more appropriate name for this method, and it isn't necessary for two methods to perform the same function under different conditions. Such simple condition discrimination is the domain of an input parameter. </P>
<P style="TEXT-INDENT: 2em">Therefore, to avoid this trap, either catch the IllegalThreadStateException or wait for the process to complete. </P>
<P style="TEXT-INDENT: 2em">Now, let's fix the problem in Listing 4.1 and wait for the process to complete. In Listing 4.2, the program again attempts to execute javac.exe and then waits for the external process to complete: </P>
<P style="TEXT-INDENT: 2em">Listing 4.2 BadExecJavac2.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">public class BadExecJavac2</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("javac");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Process exitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">Unfortunately, a run of BadExecJavac2 produces no output. The program hangs and never completes. Why does the javac process never complete? </P>
<P style="TEXT-INDENT: 2em">Why Runtime.exec() hangs </P>
<P style="TEXT-INDENT: 2em">The JDK's Javadoc documentation provides the answer to this question: </P>
<P style="TEXT-INDENT: 2em">Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock. </P>
<P style="TEXT-INDENT: 2em">Is this just a case of programmers not reading the documentation, as implied in the oft-quoted advice: read the fine manual (RTFM)? The answer is partially yes. In this case, reading the Javadoc would get you halfway there; it explains that you need to handle the streams to your external process, but it does not tell you how. </P>
<P style="TEXT-INDENT: 2em">Another variable is at play here, as is evident by the large number of programmer questions and misconceptions concerning this API in the newsgroups: though Runtime.exec() and the Process APIs seem extremely simple, that simplicity is deceiving because the simple, or obvious, use of the API is prone to error. The lesson here for the API designer is to reserve simple APIs for simple operations. Operations prone to complexities and platform-specific dependencies should reflect the domain accurately. It is possible for an abstraction to be carried too far. The JConfig library provides an example of a more complete API to handle file and process operations (see Resources below for more information). </P>
<P style="TEXT-INDENT: 2em">Now, let's follow the JDK documentation and handle the output of the javac process. When you run javac without any arguments, it produces a set of usage statements that describe how to run the program and the meaning of all the available program options. Knowing that this is going to the stderr stream, you can easily write a program to exhaust that stream before waiting for the process to exit. Listing 4.3 completes that task. While this approach will work, it is not a good general solution. Thus, Listing 4.3's program is named MediocreExecJavac; it provides only a mediocre solution. A better solution would empty both the standard error stream and the standard output stream. And the best solution would empty these streams simultaneously (I'll demonstrate that later). </P>
<P style="TEXT-INDENT: 2em">Listing 4.3 MediocreExecJavac.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">public class MediocreExecJavac</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("javac");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStream stderr = proc.getErrorStream();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStreamReader isr = new InputStreamReader(stderr);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader br = new BufferedReader(isr);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String line = null;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("&lt;ERROR&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( (line = br.readLine()) != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(line);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("&lt;/ERROR&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Process exitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">A run of MediocreExecJavac generates: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java MediocreExecJavac</P>
<P style="TEXT-INDENT: 2em">&lt;ERROR&gt;</P>
<P style="TEXT-INDENT: 2em">Usage: javac &lt;options&gt; &lt;source files&gt;</P>
<P style="TEXT-INDENT: 2em">where &lt;options&gt; includes:</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-g&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Generate all debugging info</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-g:none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate no debugging info</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-g:{lines,vars,source} Generate only some debugging info</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-O&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Optimize; may hinder debugging or enlarge class files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-nowarn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate no warnings</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-verbose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Output messages about what the compiler is doing</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-deprecation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Output source locations where deprecated APIs are used</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-classpath &lt;path&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specify where to find user class files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-sourcepath &lt;path&gt;&nbsp;&nbsp;&nbsp;&nbsp; Specify where to find input source files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-bootclasspath &lt;path&gt;&nbsp;&nbsp;Override location of bootstrap class files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-extdirs &lt;dirs&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Override location of installed extensions</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-d &lt;directory&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Specify where to place generated class files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-encoding &lt;encoding&gt;&nbsp;&nbsp; Specify character encoding used by source files</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;-target &lt;release&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate class files for specific VM version</P>
<P style="TEXT-INDENT: 2em">&lt;/ERROR&gt;</P>
<P style="TEXT-INDENT: 2em">Process exitValue: 2</P>
<P style="TEXT-INDENT: 2em">So, MediocreExecJavac works and produces an exit value of 2. Normally, an exit value of 0 indicates success; any nonzero value indicates an error. The meaning of these exit values depends on the particular operating system. A Win32 error with a value of 2 is a "file not found" error. That makes sense, since javac expects us to follow the program with the source code file to compile. </P>
<P style="TEXT-INDENT: 2em">Thus, to circumvent the second pitfall -- hanging forever in Runtime.exec() -- if the program you launch produces output or expects input, ensure that you process the input and output streams. </P>
<P style="TEXT-INDENT: 2em">Assuming a command is an executable program </P>
<P style="TEXT-INDENT: 2em">Under the Windows operating system, many new programmers stumble upon Runtime.exec() when trying to use it for nonexecutable commands like dir and copy. Subsequently, they run into Runtime.exec()'s third pitfall. Listing 4.4 demonstrates exactly that: </P>
<P style="TEXT-INDENT: 2em">Listing 4.4 BadExecWinDir.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">public class BadExecWinDir</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("dir");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStream stdin = proc.getInputStream();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStreamReader isr = new InputStreamReader(stdin);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader br = new BufferedReader(isr);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String line = null;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("&lt;OUTPUT&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( (line = br.readLine()) != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(line);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("&lt;/OUTPUT&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Process exitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">A run of BadExecWinDir produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java BadExecWinDir</P>
<P style="TEXT-INDENT: 2em">java.io.IOException: CreateProcess: dir error=2</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Win32Process.create(Native Method)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Win32Process.&lt;init&gt;(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.execInternal(Native Method)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at BadExecWinDir.main(BadExecWinDir.java:12)</P>
<P style="TEXT-INDENT: 2em">Listing 4.5 GoodWindowsExec.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">class StreamGobbler extends Thread</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;InputStream is;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;String type;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(InputStream is, String type)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.is = is;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.type = type;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public void run()</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStreamReader isr = new InputStreamReader(is);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader br = new BufferedReader(isr);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String line=null;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( (line = br.readLine()) != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(type + "&gt;" + line);&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException ioe)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ioe.printStackTrace();&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">public class GoodWindowsExec</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (args.length &lt; 1)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("USAGE: java GoodWindowsExec &lt;cmd&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.exit(1);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String osName = System.getProperty("os.name" );</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String[] cmd = new String[3];</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( osName.equals( "Windows NT" ) )</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[0] = "cmd.exe" ;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[1] = "/C" ;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[2] = args[0];</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if( osName.equals( "Windows 95" ) )</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[0] = "command.com" ;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[1] = "/C" ;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmd[2] = args[0];</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Execing " + cmd[0] + " " + cmd[1] </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + " " + cmd[2]);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec(cmd);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error message?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler errorGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getErrorStream(), "ERROR");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any output?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler outputGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getInputStream(), "OUTPUT");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// kick them off</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error???</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("ExitValue: " + exitVal);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">Running GoodWindowsExec with the dir command generates: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java GoodWindowsExec "dir *.java"</P>
<P style="TEXT-INDENT: 2em">Execing cmd.exe /C dir *.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt; Volume in drive E has no label.</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt; Volume Serial Number is 5C5F-0CC9</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt; Directory of E:\classes\com\javaworld\jpitfalls\article2</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/23/00&nbsp;&nbsp;09:01p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 805 BadExecBrowser.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/22/00&nbsp;&nbsp;09:35a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 770 BadExecBrowser1.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/24/00&nbsp;&nbsp;08:45p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 488 BadExecJavac.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/24/00&nbsp;&nbsp;08:46p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 519 BadExecJavac2.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/24/00&nbsp;&nbsp;09:13p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 930 BadExecWinDir.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/22/00&nbsp;&nbsp;09:21a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2,282 BadURLPost.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/22/00&nbsp;&nbsp;09:20a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2,273 BadURLPost1.java</P>
<P style="TEXT-INDENT: 2em">... (some output omitted for brevity)</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/12/00&nbsp;&nbsp;09:29p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 151 SuperFrame.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/24/00&nbsp;&nbsp;09:23p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1,814 TestExec.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/09/00&nbsp;&nbsp;05:47p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;23,543 TestStringReplace.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;10/12/00&nbsp;&nbsp;08:55p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 228 TopLevel.java</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;22 File(s)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 46,661 bytes</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19,678,420,992 bytes free</P>
<P style="TEXT-INDENT: 2em">ExitValue: 0</P>
<P style="TEXT-INDENT: 2em">Running GoodWindowsExec with any associated document type will launch the application associated with that document type. For example, to launch Microsoft Word to display a Word document (i.e., one with a .doc extension), type: </P>
<P style="TEXT-INDENT: 2em">&gt;java GoodWindowsExec "yourdoc.doc"</P>
<P style="TEXT-INDENT: 2em">Notice that GoodWindowsExec uses the os.name system property to determine which Windows operating system you are running -- and thus determine the appropriate command interpreter. After executing the command interpreter, handle the standard error and standard input streams with the StreamGobbler class. StreamGobbler empties any stream passed into it in a separate thread. The class uses a simple String type to denote the stream it empties when it prints the line just read to the console. </P>
<P style="TEXT-INDENT: 2em">Thus, to avoid the third pitfall related to Runtime.exec(), do not assume that a command is an executable program; know whether you are executing a standalone executable or an interpreted command. At the end of this section, I will demonstrate a simple command-line tool that will help you with that analysis. </P>
<P style="TEXT-INDENT: 2em">It is important to note that the method used to obtain a process's output stream is called getInputStream(). The thing to remember is that the API sees things from the perspective of the Java program and not the external process. Therefore, the external program's output is the Java program's input. And that logic carries over to the external program's input stream, which is an output stream to the Java program. </P>
<P style="TEXT-INDENT: 2em">Runtime.exec() is not a command line </P>
<P style="TEXT-INDENT: 2em">One final pitfall to cover with Runtime.exec() is mistakenly assuming that exec() accepts any String that your command line (or shell) accepts. Runtime.exec() is much more limited and not cross-platform. This pitfall is caused by users attempting to use the exec() method to accept a single String as a command line would. The confusion may be due to the fact that command is the parameter name for the exec() method. Thus, the programmer incorrectly associates the parameter command with anything that he or she can type on a command line, instead of associating it with a single program and its arguments. In listing 4.6 below, a user tries to execute a command and redirect its output in one call to exec(): </P>
<P style="TEXT-INDENT: 2em">Listing 4.6 BadWinRedirect.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">// StreamGobbler omitted for brevity</P>
<P style="TEXT-INDENT: 2em">public class BadWinRedirect</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("java jecho 'Hello World' &gt; test.txt");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error message?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler errorGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getErrorStream(), "ERROR");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any output?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler outputGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getInputStream(), "OUTPUT");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// kick them off</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error???</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("ExitValue: " + exitVal);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">Running BadWinRedirect produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java BadWinRedirect</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;'Hello World' &gt; test.txt</P>
<P style="TEXT-INDENT: 2em">ExitValue: 0</P>
<P style="TEXT-INDENT: 2em">The program BadWinRedirect attempted to redirect the output of an echo program's simple Java version into the file test.txt. However, we find that the file test.txt does not exist. The jecho program simply takes its command-line arguments and writes them to the standard output stream. (You will find the source for jecho in the source code available for download in Resources.) In Listing 4.6, the user assumed that you could redirect standard output into a file just as you could on a DOS command line. Nevertheless, you do not redirect the output through this approach. The incorrect assumption here is that the exec() method acts like a shell interpreter; it does not. Instead, exec() executes a single executable (a program or script). If you want to process the stream to either redirect it or pipe it into another program, you must do so programmatically, using the java.io package. Listing 4.7 properly redirects the standard output stream of the jecho process into a file. </P>
<P style="TEXT-INDENT: 2em">Listing 4.7 GoodWinRedirect.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">class StreamGobbler extends Thread</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;InputStream is;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;String type;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;OutputStream os;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(InputStream is, String type)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this(is, type, null);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(InputStream is, String type, OutputStream redirect)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.is = is;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.type = type;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.os = redirect;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public void run()</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintWriter pw = null;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (os != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pw = new PrintWriter(os);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputStreamReader isr = new InputStreamReader(is);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader br = new BufferedReader(isr);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String line=null;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( (line = br.readLine()) != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (pw != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pw.println(line);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(type + "&gt;" + line);&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (pw != null)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pw.flush();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException ioe)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ioe.printStackTrace();&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">public class GoodWinRedirect</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (args.length &lt; 1)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("USAGE java GoodWinRedirect &lt;outputfile&gt;");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.exit(1);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FileOutputStream fos = new FileOutputStream(args[0]);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec("java jecho 'Hello World'");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error message?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler errorGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getErrorStream(), "ERROR");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any output?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler outputGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getInputStream(), "OUTPUT", fos);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// kick them off</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error???</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("ExitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fos.flush();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fos.close();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">Running GoodWinRedirect produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java GoodWinRedirect test.txt</P>
<P style="TEXT-INDENT: 2em">OUTPUT&gt;'Hello World'</P>
<P style="TEXT-INDENT: 2em">ExitValue: 0</P>
<P style="TEXT-INDENT: 2em">After running GoodWinRedirect, test.txt does exist. The solution to the pitfall was to simply control the redirection by handling the external process's standard output stream separately from the Runtime.exec() method. We create a separate OutputStream, read in the filename to which we redirect the output, open the file, and write the output that we receive from the spawned process's standard output to the file. Listing 4.7 completes that task by adding a new constructor to our StreamGobbler class. The new constructor takes three arguments: the input stream to gobble, the type String that labels the stream we are gobbling, and the output stream to which we redirect the input. This new version of StreamGobbler does not break any of the code in which it was previously used, as we have not changed the existing public API -- we only extended it. </P>
<P style="TEXT-INDENT: 2em">Since the argument to Runtime.exec() is dependent on the operating system, the proper commands to use will vary from one OS to another. So, before finalizing arguments to Runtime.exec() and writing the code, quickly test the arguments. Listing 4.8 is a simple command-line utility that allows you to do just that. </P>
<P style="TEXT-INDENT: 2em">Here's a useful exercise: try to modify TestExec to redirect the standard input or standard output to a file. When executing the javac compiler on Windows 95 or Windows 98, that would solve the problem of error messages scrolling off the top of the limited command-line buffer. </P>
<P style="TEXT-INDENT: 2em">Listing 4.8 TestExec.java </P>
<P style="TEXT-INDENT: 2em">import java.util.*;</P>
<P style="TEXT-INDENT: 2em">import java.io.*;</P>
<P style="TEXT-INDENT: 2em">// class StreamGobbler omitted for brevity</P>
<P style="TEXT-INDENT: 2em">public class TestExec</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String args[])</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (args.length &lt; 1)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("USAGE: java TestExec \"cmd\"");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.exit(1);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String cmd = args[0];</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Runtime rt = Runtime.getRuntime();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process proc = rt.exec(cmd);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error message?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler errorGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getErrorStream(), "ERR");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any output?</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler outputGobbler = new </P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamGobbler(proc.getInputStream(), "OUT");</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// kick them off</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errorGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;outputGobbler.start();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// any error???</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int exitVal = proc.waitFor();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("ExitValue: " + exitVal);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">Running TestExec to launch the Netscape browser and load the Java help documentation produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java TestExec "e:\java\docs\index.html"</P>
<P style="TEXT-INDENT: 2em">java.io.IOException: CreateProcess: e:\java\docs\index.html error=193</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Win32Process.create(Native Method)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Win32Process.&lt;init&gt;(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.execInternal(Native Method)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.Runtime.exec(Unknown Source)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at TestExec.main(TestExec.java:45)</P>
<P style="TEXT-INDENT: 2em">Our first test failed with an error of 193. The Win32 error for value 193 is "not a valid Win32 application." This error tells us that no path to an associated application (e.g., Netscape) exists, and that the process cannot run an HTML file without an associated application. </P>
<P style="TEXT-INDENT: 2em">Therefore, we try the test again, this time giving it a full path to Netscape. (Alternately, we could add Netscape to our PATH environment variable.) A second run of TestExec produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java TestExec </P>
<P style="TEXT-INDENT: 2em">"e:\program files\netscape\program\netscape.exe e:\java\docs\index.html"</P>
<P style="TEXT-INDENT: 2em">ExitValue: 0</P>
<P style="TEXT-INDENT: 2em">This worked! The Netscape browser launches, and it then loads the Java help documentation. </P>
<P style="TEXT-INDENT: 2em">One additional improvement to TestExec would include a command-line switch to accept input from standard input. You would then use the Process.getOutputStream() method to pass the input to the spawned external program. </P>
<P style="TEXT-INDENT: 2em">To sum up, follow these rules of thumb to avoid the pitfalls in Runtime.exec(): You cannot obtain an exit status from an external process until it has exited You must immediately handle the input, output, and error streams from your spawned external process You must use Runtime.exec() to execute programs You cannot use Runtime.exec() like a command line </P>
<P style="TEXT-INDENT: 2em">Correction to Pitfall 3 </P>
<P style="TEXT-INDENT: 2em">In the discussion of Pitfall 3 ("Don't mix floats and doubles when generating text or XML messages") in my last column, I incorrectly stated that the different string representation of a decimal number after casting it from a float to a double was a bug. While this is a pitfall, its cause is not a bug, but the fact that the decimal numbers in question -- 100.28 and 91.09 -- do not represent precisely in binary. I'd like to thank Thomas Okken and the others who straightened me out. If you enjoy discussing the finer points of numerical methods, you can email Thomas. </P>
<P style="TEXT-INDENT: 2em">The combination of forgetting my numerical methods class, the numerous bug reports on the bug parade, and the automatic rounding of floats and doubles when printing (but not after casting a float to a double) threw me. I apologize for confusing anyone who read the article, especially to new Java programmers. I present two better solutions to the problem: </P>
<P style="TEXT-INDENT: 2em">The first possible solution is to always specify the desired rounding explicitly with NumberFormat. In my case, I use the float and double to represent dollars and cents; therefore, I need only two significant digits. Listing C3.1 demonstrates how to use the NumberFormat class to specify a maximum of two fraction digits. </P>
<P style="TEXT-INDENT: 2em">Listing C3.1 FormatNumbers.java </P>
<P style="TEXT-INDENT: 2em">import java.text.*;</P>
<P style="TEXT-INDENT: 2em">public class FormatNumbers</P>
<P style="TEXT-INDENT: 2em">{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String [] args)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NumberFormat fmt = NumberFormat.getInstance();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fmt.setMaximumFractionDigits(2);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float f = 100.28f;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("As a float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: " + f);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double d = f;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Cast to a double&nbsp;&nbsp;: " + d);</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("Using NumberFormat: " + fmt.format(d));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Throwable t)</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.printStackTrace();</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</P>
<P style="TEXT-INDENT: 2em">&nbsp;&nbsp;&nbsp;&nbsp;}</P>
<P style="TEXT-INDENT: 2em">}</P>
<P style="TEXT-INDENT: 2em">When we run the FormatNumbers program, it produces: </P>
<P style="TEXT-INDENT: 2em">E:\classes\com\javaworld\jpitfalls\article2&gt;java FormatNumbers</P>
<P style="TEXT-INDENT: 2em">As a float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 100.28</P>
<P style="TEXT-INDENT: 2em">Cast to a double&nbsp;&nbsp;: 100.27999877929688</P>
<P style="TEXT-INDENT: 2em">Using NumberFormat: 100.28</P>
<P style="TEXT-INDENT: 2em">As you can see -- regardless of whether we cast the float to a double -- when we specify the number of digits we want, it properly rounds to that precision -- even if the number is infinitely repeating in binary. To circumvent this pitfall, control the formatting of your doubles and floats when converting to a String. </P>
<P style="TEXT-INDENT: 2em">A second, simpler solution would be to not use a float to represent cents. Integers (number of pennies) can represent cents, with a legal range of 0 to 99. You can check the range in the mutator method. </P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em">评论：没有评论。</P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em">发表评论请输入评论</P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em"></P>
<P style="TEXT-INDENT: 2em">引文来源&nbsp;&nbsp;<A href="http://blog.csdn.net/westwin/archive/2005/04/22/358377.aspx">(转贴)Runtime.exec()的陷阱 - westwin的专栏 - CSDNBlog</A></P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200871112950108</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200871112950108</guid>
    <pubDate>Fri, 1 Aug 2008 11:29:50 +0800</pubDate>
    <dcterms:modified>2008-08-01T17:19:23+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[再发个精彩Parkour视频——David]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/2744844820087184445556</link>
    <description><![CDATA[<div><P><EMBED allowScriptAccess="never" allowNetworking="internal" style="DISPLAY: block" src=http://www.56.com/u63/v_MjI0MzQzMzI.html autostart="0" loop="0"  ></EMBED></P><EMBED allowScriptAccess="never" allowNetworking="internal" style="DISPLAY: block; WIDTH: 405px; HEIGHT: 335px; TEXT-ALIGN: center" pluginspage=http://www.macromedia.com/go/getflashplayer src=http://www.56.com/n_v156_/c9_/15_/24_/zht_king_/zhajm_119451726249x_/169000_/0_/22434332.swf type=application/x-shockwave-flash wmode="transparent" quality="high"  >&nbsp;</div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/2744844820087184445556</comments>
    <slash:comments>4</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/2744844820087184445556</guid>
    <pubDate>Fri, 1 Aug 2008 08:44:45 +0800</pubDate>
    <dcterms:modified>2008-08-01T08:47:43+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[美女Kat2008新跑酷视频[转自跑酷网]]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/2744844820087181618756</link>
    <description><![CDATA[<div><P>&nbsp;</P>
<P>I Love parkour!<EMBED allowScriptAccess="never" allowNetworking="internal" style="DISPLAY: block; WIDTH: 461px; HEIGHT: 339px; TEXT-ALIGN: center" pluginspage=http://www.macromedia.com/go/getflashplayer src=http://player.youku.com/player.php/sid/XMjUyNjU3MTI=/v.swf type=application/x-shockwave-flash wmode="transparent" quality="high"  ></EMBED>&nbsp;</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/2744844820087181618756</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/2744844820087181618756</guid>
    <pubDate>Fri, 1 Aug 2008 08:16:18 +0800</pubDate>
    <dcterms:modified>2008-08-01T08:48:13+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[看了让人心疼的签名[转]]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/2744844820086299406461</link>
    <description><![CDATA[<div><TABLE>
<TBODY></TBODY></TABLE>
<TABLE>1. 如果以后你会不经意地想起我，请别忘记我曾那样深深地爱过你……&nbsp; &nbsp; &nbsp; <BR><BR>&nbsp; 2. 踮起脚尖，我们就能离幸福更近一点吗？&nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; <BR>&nbsp; 3.我真的喜欢你,闭上眼,以为我能忘记,但流下的眼泪,却没有骗到自己。&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 4.亲爱的，出去玩累了、受伤了的话就回来吧，我还在这里等你……&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 5.当你眼泪忍不住要流出来的时候，睁大眼睛，千万别眨眼！你会看到世界由清晰变模糊的全过程，心会在你泪水落下的那一刻变得清澈明晰……　&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 6.人生就像一场舞会，教会你最初舞步的人却未必能陪你走到散场……&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 7.不爱的爱情，永远不会变坏。&nbsp; 所以，我们调情，我们暧昧，却永远不要相爱。 <BR>&nbsp; &nbsp; <BR>&nbsp; 8.其实我是一直相信的，我根本不需要想起什麼，因为我从来没有忘记过。 <BR>&nbsp; &nbsp; <BR>&nbsp; 9.最浪漫的三个字不是“我爱你”，而是“在一起”。 <BR>&nbsp; &nbsp; <BR>&nbsp; 10.不要轻易说爱,许下的诺言就是欠下的债。 <BR>&nbsp; &nbsp; <BR>&nbsp; 11.分手后不可以做朋友,因为彼此伤害过,不可以做敌人,因为彼此深爱过,所以我们变成了最熟悉的陌生人…… <BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; 12.我放下尊严,放下了个性,放下了固执,都是因为放不下你…… <BR>&nbsp; &nbsp; <BR>&nbsp; 13.那些曾经以为念念不忘的事情就在我们念念不忘的过程里，被我们遗忘了。 <BR>&nbsp; &nbsp; <BR>&nbsp; 14.寂寞的人总是会用心的记住他生命中出现过的每一个人，于是我总是意犹未尽地想起你在每个星光陨落的晚上一遍一遍数我的寂寞。 <BR>&nbsp; &nbsp; <BR>&nbsp; 15.我生命里的温暖就那么多，我全部给了你，但是你离开了我，你叫我以后怎么再对别人笑…… <BR>&nbsp; &nbsp; <BR>&nbsp; 16.躲在某一时间，想念一段时光的掌纹；躲在某一地点，想念一个站在来路也站在去路的，让我牵挂的人。&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 17.有些人会一直刻在记忆里的，即使忘记了他的声音，忘记了他的笑容，忘记了他的脸，但是每当想起他时的那种感受，是永远都不会改变的。&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 18.那些以前说着永不分离的人，早已经散落在天涯了。 <BR>&nbsp; &nbsp; <BR>&nbsp; 19.你永远也看不到我最寂寞时候的样子，因为只有你不在我身边的时候，我才最寂寞。 <BR>&nbsp; &nbsp; <BR>&nbsp; 20.记忆想是倒在掌心的水不论你摊开还是紧握终究还是会从指缝中一滴一滴流淌干净。 <BR>&nbsp; &nbsp; <BR>&nbsp; 21.伤口就像我一样，是个倔强的孩子，不肯愈合，因为内心是温暖潮湿的地方，适合任何东西生长。 <BR>&nbsp; &nbsp; <BR>&nbsp; 22.这世上最累的事情，莫过于眼睁睁看着自己的心碎了，还得自己动手把它粘起来。 <BR>&nbsp; &nbsp; <BR>&nbsp; 23.如果有一天我们在路上重逢，而我告诉你：“我现在很幸福。”我一定是伪装的 如果只能够跟你重逢，而不是共同生活，那怎么会幸福呢？告诉你我很幸福， 只是不想让你知道我其实很伤心。&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 24.离别与重逢，是人生不停上演的戏，习惯了，也就不再悲怆。&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 25.我们在错误的时间相遇，在正确的时间却又分开…… <BR>&nbsp; &nbsp; <BR>&nbsp; 26.该笑的时候没有快乐，该哭泣的时候没有眼泪，该相信的时候没有诺言。 <BR>&nbsp; &nbsp; <BR>&nbsp; 27.那些离别和失望的伤痛，已经发不出声音来了。 <BR>&nbsp; &nbsp; <BR>&nbsp; 28.我相信我爱你。依然。始终。永远。 <BR>&nbsp; &nbsp; &nbsp; <BR>&nbsp; 29.他说：“你会找到一个比我更好的人。” 你微笑说：“但我不会再对人这么好了。”&nbsp; <BR>
<TBODY></TBODY></TABLE>
<TABLE>
<TBODY></TBODY></TABLE><BR><p>----------------------------<br/>一键转贴，快速捕捉生活精彩，赢每周好礼！<a href="http://blog.163.com/activities/hunter/hunter.do?080526jclr46" target="_blank">查看活动首页&gt;&gt;</a></p></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/2744844820086299406461</comments>
    <slash:comments>3</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/2744844820086299406461</guid>
    <pubDate>Tue, 29 Jul 2008 09:40:06 +0800</pubDate>
    <dcterms:modified>2008-07-29T09:40:06+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[open-open添加Ajax专栏]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200862501433907</link>
    <description><![CDATA[<div><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="http://www.open-open.com/ajax/">http://www.open-open.com/ajax/</A></P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 真是越来越爱你了！</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200862501433907</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200862501433907</guid>
    <pubDate>Fri, 25 Jul 2008 12:14:33 +0800</pubDate>
    <dcterms:modified>2008-07-25T12:14:33+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[《Rails项目实战剖析与技巧大全》发布订购信息]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200862115423832</link>
    <description><![CDATA[<div><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 由我、王铮、马连浩共同翻译的<FONT color=#000000><STRONG><FONT color=#ff0000>《Rails项目实战剖析与技巧大全》</FONT></STRONG></FONT>&nbsp;一书，已经在电子工业出版社的网站上发布了订购信息，相信马上就能与大家见面了。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PS： 其中的内容简介不知道是谁写的，我不是太满意。。。可能是考虑到我比较忙，出版社自己搞定了，不管怎样，还是感谢一下：）</P>
<P style="TEXT-INDENT: 2em">地址如下</P>
<P style="TEXT-INDENT: 2em"><A href="http://www.phei.com.cn/bookshop/bookinfo.asp?bookcode=TP068770%20&amp;booktype=main">http://www.phei.com.cn/bookshop/bookinfo.asp?bookcode=TP068770%20&amp;booktype=main</A> </P>
<P style="TEXT-INDENT: 2em">现在正在翻《Ajax Security》一书，说实话，这本书写的真是挺好的（绝不是老王买瓜）。幸好以前做过很多网络安全方面的研究，现在在Ajax开发中结合思考一下，发现以前写的许多程序还是挺危险的（自己寒一个）。。。不过内容比较多，翻译的时间可能会稍微长些，也是本着对读者负责的态度，希望朋友们不要着急，估计12月份能够上市。 </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200862115423832</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200862115423832</guid>
    <pubDate>Mon, 21 Jul 2008 13:54:23 +0800</pubDate>
    <dcterms:modified>2008-07-21T13:56:03+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[感悟十句话（天涯转载)]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/274484482008621133477</link>
    <description><![CDATA[<div><CENTER>
<DIV><BR><BR>
<DIV>
<DIV><BR>第一句<BR><BR>如果我们之间有1000步的距离<BR>你只要跨出第1步<BR>我就会朝你的方向走其余的999步<BR><BR><BR>第二句<BR><BR>通常愿意留下来跟你争吵的人<BR>才是真正爱你的人<BR><BR><BR>第三句<BR><BR>付出真心才会得到真心<BR>却也可能伤得彻底<BR>保持距离就能避免伤害却也注定永远寂寞<BR><BR><BR>第四句<BR><BR>有时候不是对方不在乎你<BR>而是你把对方看得太重<BR><BR><BR>第五句<BR><BR>朋友就是把你看透了还能喜欢你的人<BR> <BR><BR>第六句<BR><BR>就算是believe中间也藏了一个lie<BR><BR><BR>第七句<BR><BR>真正的好朋友<BR>并不是在一起就有聊不完的话题<BR>而是在一起就算不说话<BR>也不会感到尴尬<BR><BR><BR>第八句<BR><BR>没有一百分的另一半<BR>只有五十分的两个人<BR><BR><BR>第九句<BR><BR>为你的难过而快乐的是敌人<BR>为你的快乐而快乐的是朋友<BR>为你的难过而难过的<BR>就是那些该放进心里的人<BR><BR><BR>第十句<BR><BR>冷漠有时候并不是无情<BR>只是一种避免被伤害的工具<BR><BR></DIV></DIV></DIV></CENTER><BR><BR><BR>引文来源&nbsp;&nbsp;<A href="http://cache.tianya.cn/techforum/content/14/751284.shtml" target=_blank>[生活五味]十句话，我竟然看了好久...(转载)</A><p>----------------------------<br/>一键转贴，快速捕捉生活精彩，赢每周好礼！<a href="http://blog.163.com/activities/hunter/hunter.do?080526jclr46" target="_blank">查看活动首页&gt;&gt;</a></p></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/274484482008621133477</comments>
    <slash:comments>3</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/274484482008621133477</guid>
    <pubDate>Mon, 21 Jul 2008 01:03:34 +0800</pubDate>
    <dcterms:modified>2008-07-21T01:03:34+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[修改后的scriptaculous AutoComplete，支持中文、Focus事件]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200861610812832</link>
    <description><![CDATA[<div><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最近在项目中要做Google Suggestion的效果，采用了Scriptaculous的AutoComplete控件，后发现其对中文支持不是很好，而且没有Focus事件，所以修改了一下源代码，在此分享。</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 关于中文，我是进行了两次encodeURIComponent编码，修改代码中的</P>
<P>Ajax.Autocompleter = Class.create(Autocompleter.Base, {<BR>&nbsp; initialize: function(element, update, url, options) {<BR>&nbsp;&nbsp;&nbsp; this.baseInitialize(element, update, options);<BR>&nbsp;&nbsp;&nbsp; this.options.asynchronous&nbsp; = true;<BR>&nbsp;&nbsp;&nbsp; this.options.onComplete&nbsp;&nbsp;&nbsp; = this.onComplete.bind(this);<BR>&nbsp;&nbsp;&nbsp; this.options.defaultParams = this.options.parameters || null;<BR>&nbsp;&nbsp;&nbsp; this.url&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = url;<BR>&nbsp; },</P>
<P>&nbsp; getUpdatedChoices: function() {<BR>&nbsp;&nbsp;&nbsp; this.startIndicator();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <STRONG><FONT color=#ff0000>var entry = encodeURIComponent(this.options.paramName) + '=' + <BR></FONT></STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#ff0000><STRONG> encodeURIComponent(encodeURIComponent(this.getToken()));<BR></STRONG></FONT>&nbsp;&nbsp;&nbsp; this.options.parameters = this.options.callback ?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.options.callback(this.element, entry) : entry;</P>
<P>&nbsp;&nbsp;&nbsp; if(this.options.defaultParams) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.options.parameters += '&amp;' + this.options.defaultParams;<BR>&nbsp;&nbsp;&nbsp; new Ajax.Request(this.url, this.options);<BR>&nbsp; },</P>
<P>&nbsp; onComplete: function(request) {<BR>&nbsp;&nbsp;&nbsp; this.updateChoices(request.responseText);<BR>&nbsp; }<BR>});</P>
<P>在Java中用</P>
<P>String name = java.net.URLDecoder.decode(request.getParameter("name"),"UTF-8");</P>
<P>就可以取出</P>
<P>&nbsp;</P>
<P>focus事件</P>
<P>&nbsp;&nbsp;&nbsp; Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));<BR>&nbsp;&nbsp;&nbsp; Event.observe(this.element, 'keyup', this.onKeyPress.bindAsEventListener(this));</P>
<P>添加</P>
<P><FONT color=#ff0000><STRONG>&nbsp;&nbsp;&nbsp; Event.observe(this.element, 'focus', this.onFocus.bindAsEventListener(this));</STRONG></FONT></P>
<P><FONT color=#000000>然后添加方法</FONT></P>
<P>activate: function() {<BR>&nbsp;&nbsp;&nbsp; this.changed = false;<BR>&nbsp;&nbsp;&nbsp; this.hasFocus = true;<BR>&nbsp;&nbsp;&nbsp; this.getUpdatedChoices();<BR>&nbsp; },</P>
<P>onFocus: function() {<BR>&nbsp;&nbsp;&nbsp; this.changed = false;<BR>&nbsp;&nbsp;&nbsp; this.hasFocus = true;<BR>&nbsp;&nbsp;&nbsp; this.getUpdatedChoices();<BR>&nbsp; },</P>
<P>或者直接</P>
<P><STRONG><FONT color=#ff0000>&nbsp;Event.observe(this.element, 'focus', this.activate.bindAsEventListener(this));</FONT></STRONG></P>
<P><FONT color=#000000>JQuery的插件也存在相应的问题，也可以这样来修改</FONT></P>
<P>&nbsp;</P></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200861610812832</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200861610812832</guid>
    <pubDate>Wed, 16 Jul 2008 22:08:12 +0800</pubDate>
    <dcterms:modified>2008-07-20T15:01:46+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[超强火影图!!!!!!!!]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200863201605</link>
    <description><![CDATA[<div><TABLE>贴子相关图片: <BR><IMG height=450 src="http://comic.qq.com/images/comic/2005/07/22/tr/01.jpg" width=486 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=470 src="http://comic.qq.com/images/comic/2005/07/22/tr/02.jpg" width=485 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=218 src="http://comic.qq.com/images/comic/2005/07/22/tr/04.jpg" width=450 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=317 src="http://comic.qq.com/images/comic/2005/07/22/tr/05.jpg" width=567 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=303 src="http://comic.qq.com/images/comic/2005/07/22/tr/06.jpg" width=444 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=522 src="http://comic.qq.com/images/comic/2005/07/22/tr/07.jpg" width=408 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=384 src="http://comic.qq.com/images/comic/2005/07/22/tr/08.jpg" width=400 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=291 src="http://comic.qq.com/images/comic/2005/07/22/tr/09.jpg" width=293 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=446 src="http://comic.qq.com/images/comic/2005/07/22/tr/10.jpg" width=446 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=455 src="http://comic.qq.com/images/comic/2005/07/22/tr/11.jpg" width=576 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=456 src="http://comic.qq.com/images/comic/2005/07/22/tr/12.jpg" width=439 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=531 src="http://comic.qq.com/images/comic/2005/07/22/tr/13.jpg" width=477 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=456 src="http://comic.qq.com/images/comic/2005/07/22/tr/14.jpg" width=394 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=449 src="http://comic.qq.com/images/comic/2005/07/22/tr/15.jpg" width=412 border=0>
<TBODY></TBODY></TABLE>
<TABLE>贴子相关图片: <BR><IMG height=496 src="http://comic.qq.com/images/comic/2005/07/22/tr/16.jpg" width=747 border=0>
<TBODY></TBODY></TABLE><BR><BR><BR><BR>引文来源&nbsp;&nbsp;<A href="http://tieba.baidu.com/f?kz=91674954" target=_blank>百度_火影忍者吧_超强的图!!!!!!!!</A><p>----------------------------<br/>一键转贴，快速捕捉生活精彩，赢每周好礼！<a href="http://blog.163.com/activities/hunter/hunter.do?080526jclr46" target="_blank">查看活动首页&gt;&gt;</a></p></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/27448448200863201605</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/27448448200863201605</guid>
    <pubDate>Thu, 3 Jul 2008 14:00:01 +0800</pubDate>
    <dcterms:modified>2008-07-03T14:00:01+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[谷歌总部员工的“腐败”生活]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/2744844820085281013841</link>
    <description><![CDATA[<div><div >
        <h1 >谷歌总部员工的“腐败”生活</h1>
        <div >2008-06-28 08:54:22　来源: <a href="http://tech.163.com/08/0628/08/4FGV0551000915BF.html#" target="_blank">千龙网</a>　<a href="http://comment.tech.163.com/tech_bbs/4FGV0551000915BF.html"  >网友评论 <span  >27</span> 条</a> <a href="http://bbs.tech.163.com/">进入论坛</a></div>
      </div>
<div >
<ul><li>
<span >　　美国《时代周刊》又发布了一组有关Google总部Googleplex的照片，看罢不禁感慨：人家怎么能把美容院、高尔夫球场、游乐园、游泳池……都搬到公司里？</span>
</li></ul>
</div>


<p style="text-indent: 2em;"><clk>作为世界最著名的搜索引擎之一，Google公司的市值已飙升至500亿英镑。想象中在这种大公司<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,0)" target="_blank" false;" this);"  >工作</nobr>必定会忙得呼喘气都得计算时间，事实上Google美国总部内部的工作环境却以不拘一格出名：员工没有专门制服，他们爱穿什么就穿什么。甚至连老板的办公桌上也乱糟糟地堆着一堆儿童拼装玩具！前去采访的美国记者都大跌眼镜。</clk></p>
<p style="text-indent: 2em;"><clk>这不，不久前，<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,8)" target="_blank" false;" this);"  >美国</nobr>《时代周刊》又发布了一组有关Google总部Googleplex的照片，看罢不禁感慨：人家怎么能把美容院、高尔夫球场、游乐园、游泳池……都搬到<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,2)" target="_blank" false;" this);"  >公司</nobr>里？员工还能带着自己的狗狗来上班？唉，“腐败”呀！可是，这样的工作谁不爱？难怪李开复博士也被挖了过来…… </clk></p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/2008062808500210c91.jpg" border="0"></center>


<p style="text-indent: 2em;">Google总部Googleplex位于美国加州山景城，图为Google员工使用滑板车往来于不同的工作场所。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img2.cache.netease.com/tech/2008/6/28/200806280850126cb70.jpg" border="0"></center>


<p style="text-indent: 2em;"><clk>桌上的各类小玩意和熔岩灯向<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,1)" target="_blank" false;" this);"  >我们</nobr>展示了Google宽松的工作环境。</clk></p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/200806280850223c65d.jpg" border="0"></center>


<p style="text-indent: 2em;">技术人员24小时待命，计算机或其他数码产品可以随时送修。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img2.cache.netease.com/tech/2008/6/28/200806280850312a7ce.jpg" border="0"></center>


<p style="text-indent: 2em;">Google员工在公司总部的迷你泳池内游泳（居然还配备了救生员！）。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img2.cache.netease.com/tech/2008/6/28/200806280850398f4de.jpg" border="0"></center>


<p style="text-indent: 2em;">两名Google员工坐在灵感涂鸦板前享用工间咖啡。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/2008062808504876870.jpg" border="0"></center>


<p style="text-indent: 2em;">在员工休息室打桌球。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/2008062808505621c15.jpg" border="0"></center>


<p style="text-indent: 2em;"><clk>Google与专业发型设计师签有合约，员工在这里美发可以<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,3)" target="_blank" false;" this);"  >打折</nobr>。</clk></p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/200806280851047bbbd.jpg" border="0"></center>

<p style="text-indent: 2em;">午休时间，Google员工在公司沙地球场打排球。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/20080628085128f4ddb.jpg" border="0"></center>


<p style="text-indent: 2em;">Google每天三次向员工提供美味餐点，图为员工在自助餐厅就餐，墙上所挂绘画作品均为Google员工自己所作。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img2.cache.netease.com/tech/2008/6/28/2008062808513740b28.jpg" border="0"></center>


<p style="text-indent: 2em;">公司内部员工子女托管中心，当然各类电动玩具必不可少。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img1.cache.netease.com/tech/2008/6/28/200806280851484c8bb.jpg" border="0"></center>


<p style="text-indent: 2em;">Google员工可到公司赞助的按摩休息室按摩，消除一日的工作疲劳。</p>
<p style="text-indent: 2em;">
</p><center><img src="http://img2.cache.netease.com/tech/2008/6/28/200806280851585d1f9.jpg" border="0"></center>


<p style="text-indent: 2em;">Google的员工甚至可以带上自己的宠物狗到公司上班！（但不可以带猫）。</p>
<p style="text-indent: 2em;"><clk>Google总部的工作环境轻松写意，摒弃了一般<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,7)" target="_blank" false;" this);"  >企业</nobr>所具有的繁文缛节，处处体现以人为本的管理理念，正如一位公司代表所言，“我们没有正式的公司文化，因为这样比较容易激发<nobr  style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" kwC(event,4)" target="_blank" false;" this);"  >创意</nobr>和灵感。” 
</clk><a href="http://tech.163.com/"><img src="http://tech.163.com/newimg/arc_d.gif" alt="kenny"  width="12" border="0" height="11"></a>
</p><p style="text-indent: 2em;">&nbsp;</p></div>]]></description>
	    <author><![CDATA[Alfred]]></author>
	    <comments>http://tjligong.blog.163.com/blog/static/2744844820085281013841</comments>
    <slash:comments>4</slash:comments>
    <guid isPermaLink="true">http://tjligong.blog.163.com/blog/static/2744844820085281013841</guid>
    <pubDate>Sat, 28 Jun 2008 10:01:38 +0800</pubDate>
    <dcterms:modified>2008-06-28T10:01:38+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[中国地震科考队称在四川取得世界级突破]]></title>	
    <link>http://tjligong.blog.163.com/blog/static/27448448200852495130427</link>
    <description><![CDATA[<div><p style="text-indent: 2em;">看留言就行了，我就不发表什么评论了。。。<br></p><p style="text-indent: 2em;">据 <a href="http://news.163.com" target="_blank">网易新闻</a> 报道： <a href="http://news.163.com/08/0623/11/4F4BUKU200011SM9.html" target="_blank">中国地震科考队称在四川取得世界级突破</a></p><p style="text-indent: 2em;">核心提示：科考队在地震当天赶赴四川，首先进行救援，之后做评估、科考。获得的第一首数据将为震后重建提供防震数据。<a href="http://news.163.com/08/0623/11/4F4BUKU200011SM9.html" target="_blank">查看全文&gt;&gt;</a></p><p><strong>网易网友对这条新闻的看法是：</strong></p><p>
      </p><div >
                
    <div  >
      <div >
                   网易重庆网友 <span  >ip：125.83.*.*：</span>
            </div> 
        
 <div >2008-06-23 11:44:06 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">是,这次地震他们功劳最大.</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4CNANR" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CNANR&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4CNANR');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CNANR&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4CNANR&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4CNANR');" target="_self" >支持</a>[<span >1023</span>] <a  href=";postid=4F4BUKU200011SM9_4F4CNANR','voteAgainstNumber_4F4BUKU200011SM9_4F4CNANR');" target="_self">反对</a>[<span >54</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易重庆网友 <span  >ip：61.186.*.*：</span>
            </div> 
        
 <div >2008-06-23 11:46:42 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">吹牛取得世界级突破</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4CS3PG" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CS3PG&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4CS3PG');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CS3PG&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4CS3PG&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4CS3PG');" target="_self" >支持</a>[<span >912</span>] <a  href=";postid=4F4BUKU200011SM9_4F4CS3PG','voteAgainstNumber_4F4BUKU200011SM9_4F4CS3PG');" target="_self">反对</a>[<span >25</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易四川成都网友 <span  >ip：221.237.*.*：</span>
            </div> 
        
 <div >2008-06-23 11:47:38 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">现在看到这些砖家就想给他一火砖</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4CTPMU" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CTPMU&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4CTPMU');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CTPMU&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4CTPMU&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4CTPMU');" target="_self" >支持</a>[<span >714</span>] <a  href=";postid=4F4BUKU200011SM9_4F4CTPMU','voteAgainstNumber_4F4BUKU200011SM9_4F4CTPMU');" target="_self">反对</a>[<span >16</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易广东深圳网友 <span  >ip：116.24.*.*：</span>
            </div> 
        
 <div >2008-06-23 11:42:08 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">可别写这样刺激的标题了</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4CJNHC" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CJNHC&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4CJNHC');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4CJNHC&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4CJNHC&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4CJNHC');" target="_self" >支持</a>[<span >507</span>] <a  href=";postid=4F4BUKU200011SM9_4F4CJNHC','voteAgainstNumber_4F4BUKU200011SM9_4F4CJNHC');" target="_self">反对</a>[<span >4</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易广东广州天河网友 <span  >ip：61.144.*.*：</span>
            </div> 
        
 <div >2008-06-23 12:53:54 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">砖家走向世界了，吹出地球，吹向火星，</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4GN4U1" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4GN4U1&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4GN4U1');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4GN4U1&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4GN4U1&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4GN4U1');" target="_self" >支持</a>[<span >498</span>] <a  href=";postid=4F4BUKU200011SM9_4F4GN4U1','voteAgainstNumber_4F4BUKU200011SM9_4F4GN4U1');" target="_self">反对</a>[<span >6</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易广东广州网友 <span  >ip：59.41.*.*：</span>
            </div> 
        
 <div >2008-06-23 13:43:43 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">建议把地震局划归计生委，那样才好算世界级的成果。</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4JIBL2" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4JIBL2&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4JIBL2');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4JIBL2&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4JIBL2&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4JIBL2');" target="_self" >支持</a>[<span >439</span>] <a  href=";postid=4F4BUKU200011SM9_4F4JIBL2','voteAgainstNumber_4F4BUKU200011SM9_4F4JIBL2');" target="_self">反对</a>[<span >5</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易江西南昌网友 <span  >ip：59.53.*.*：</span>
            </div> 
        
 <div >2008-06-23 12:05:57 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">一群猪．喂饱了</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4DVBHU" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DVBHU&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4DVBHU');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DVBHU&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4DVBHU&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4DVBHU');" target="_self" >支持</a>[<span >391</span>] <a  href=";postid=4F4BUKU200011SM9_4F4DVBHU','voteAgainstNumber_4F4BUKU200011SM9_4F4DVBHU');" target="_self">反对</a>[<span >9</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易安徽蚌埠网友 <span  >ip：218.23.*.*：</span>
            </div> 
        
 <div >2008-06-23 12:03:08 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">养砖家不如养只狗,还能看门和预警.</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4DQ6H4" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DQ6H4&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4DQ6H4');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DQ6H4&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4DQ6H4&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4DQ6H4');" target="_self" >支持</a>[<span >388</span>] <a  href=";postid=4F4BUKU200011SM9_4F4DQ6H4','voteAgainstNumber_4F4BUKU200011SM9_4F4DQ6H4');" target="_self">反对</a>[<span >6</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易北京海淀网友 <span  >ip：221.219.*.*：</span>
            </div> 
        
 <div >2008-06-23 12:01:24 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">真恶心!!!</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4DN0PJ" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DN0PJ&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4DN0PJ');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4DN0PJ&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4DN0PJ&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4DN0PJ');" target="_self" >支持</a>[<span >327</span>] <a  href=";postid=4F4BUKU200011SM9_4F4DN0PJ','voteAgainstNumber_4F4BUKU200011SM9_4F4DN0PJ');" target="_self">反对</a>[<span >6</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易浙江台州网友 <span  >ip：123.153.*.*：</span>
            </div> 
        
 <div >2008-06-23 11:54:14 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">忽悠，继续忽悠</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F4D9SUA" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4D9SUA&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F4D9SUA');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F4D9SUA&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F4D9SUA&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F4D9SUA');" target="_self" >支持</a>[<span >316</span>] <a  href=";postid=4F4BUKU200011SM9_4F4D9SUA','voteAgainstNumber_4F4BUKU200011SM9_4F4D9SUA');" target="_self">反对</a>[<span >6</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    

      <div >网友评论仅供网友表达个人看法，并不表明网易同意其观点或证实其描述</div>
   </div>
 
<!-- 最新评论 -->
  <a ></a>
         <div >
            <h5>最新评论</h5>
            <div > 
            <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#"  target="_self">评论共<span  fB">1376</span>条 显示<span fB">1123</span>条</a>
            <!-- <a href="#"  target="_self">评论共<span  fB">1123</span>条</a> -->
            </div>
        </div>
    
  <!--  hidden item start -->
  
  <div  style="display: none;">
      <div >
        <div >（本跟帖正在审核，请耐心等候）</div><br>
        <div  >网易XXX网友&nbsp;[<a href="http://comment.news.163.com/news_guonei7_bbs/XXX%28XXX">XXX</a>]：</div>
        <div  >XXX 发表</div>
      </div>
      <div  >XXX</div>
      <div  >
        <a href="http://comment.news.163.com/news_guonei7_bbs/XXX" rel="XXX" >回复</a> 
     <!-- <a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=XXX&rb=XXX">精华推荐</a>-->
     <!-- <a href="">引用到博客</a>-->
     <a href=";" target="_self">收藏到博客</a>
        <a  href=";postid=XXX&amp;flag=XXX','voteForNumber_XXX');" target="_self" >支持</a>
        (<span >0</span>) <a  href=";postid=XXX','voteAgainstNumber_XXX');" target="_self">反对</a>(<span >0</span>)
        <a href=";">举报</a> <span  ></span>
      </div>
      
  </div>
  <!--  hidden item end -->
        
    <div  >
      <div >
                   网易天津网友 <span  >ip：117.8.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:49:29 发表</div> 
    </div>
    <div  ><div style="border: 1px solid rgb(153, 153, 153); padding: 3px; background: rgb(255, 255, 238) none repeat scroll 0% 0%; overflow: hidden; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: 12px; text-align: left; line-height: 0pt;"><span style="padding: 5px 3px; font-size: 12px; line-height: 20px; color: rgb(31, 58, 135); text-align: left;">网易北京海淀网友(61.51.*.*) 的原贴：</span><p style="margin: 9px 3px; line-height: 20px; text-align: left; color: rgb(0, 0, 0);">全是废话：<br>孔
繁钰主任还介绍说：“可能很多人不知道，其实我国的地震研究水平处于世界领先地位，我所的第一任所长、原中国科学院学部委员刘恢先，曾被业界称为‘世界地
震工程之父’。在世界地震工程领域，中国与美国、日本一起被列入综合实力雄厚的第一科研梯队，由此可见我国在这一领域所取得的成就。” <br>为什么地震前不知道要发生地震，地震后确却要站出来丢人。为什么不把这帮吃白饭的人给抓起来？</p></div><span style="padding: 5px 3px; font-size: 12px; line-height: 20px; color: rgb(31, 58, 135); text-align: left;"></span><p style="margin: 9px 3px; line-height: 20px; text-align: left; color: rgb(0, 0, 0);">日本有提前10秒预报，这些专家呢？<br>中国地震局Cao-SB</p></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6OI6J9" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OI6J9&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6OI6J9');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OI6J9&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6OI6J9&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6OI6J9');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6OI6J9','voteAgainstNumber_4F4BUKU200011SM9_4F6OI6J9');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易浙江金华网友 <span  >ip：125.113.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:48:25 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">看了半天,没看出来到底啥是突破性成果......都怪偶读书太少啊,看来15年不够,以后免费教育要15年,再加其他要读50年才行.</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6OG7GE" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OG7GE&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6OG7GE');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OG7GE&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6OG7GE&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6OG7GE');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6OG7GE','voteAgainstNumber_4F4BUKU200011SM9_4F6OG7GE');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易广东广州网友 <span  >ip：116.23.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:46:12 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">这个记者有问题,说了尽让人骂,第一次见这么牛B的</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6OC5GS" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OC5GS&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6OC5GS');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OC5GS&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6OC5GS&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6OC5GS');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6OC5GS','voteAgainstNumber_4F4BUKU200011SM9_4F6OC5GS');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易山东临沂网友 <span  >ip：222.132.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:45:19 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">死劲吹吧！！！反正又没法验正！！！！</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6OAI4U" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OAI4U&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6OAI4U');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OAI4U&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6OAI4U&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6OAI4U');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6OAI4U','voteAgainstNumber_4F4BUKU200011SM9_4F6OAI4U');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易江苏苏州网友 <span  >ip：58.211.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:45:08 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">官僚给自己脸上贴金<br>写这篇文的记者走狗一个<br>看了后总感觉这次地震他们这帮人功劳最大!!!</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6OA7GG" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OA7GG&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6OA7GG');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6OA7GG&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6OA7GG&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6OA7GG');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6OA7GG','voteAgainstNumber_4F4BUKU200011SM9_4F6OA7GG');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                   网易广东广州网友 <span  >ip：116.23.*.*：</span>
            </div> 
        
 <div >2008-06-24 09:44:29 发表</div> 
    </div>
    <div  ><div style="width: 90%; line-height: 20px;">标题看了让人兴奋,看了真的想骂人,他妈的,那也是世界级啊?就是出事了看看那也是世界级吗?唐山记录了吧,还不是一样来个汶川?</div></div>
    
    <div >
  
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html###" rel="4F4BUKU200011SM9_4F6O90RL" >回复</a> 
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6O90RL&rb=news_guonei7_bbs">引用到博客</a>-->
  <a href="http://comment.news.163.com/news_guonei7_bbs/4F4BUKU200011SM9.html#" 4F4BUKU200011SM9_4F6O90RL');" target="_self">收藏到博客</a>
  <!--<a href="http://bbs9.news.163.com/board/zt.jsp?b=newsreply&replyid=4F4BUKU200011SM9_4F6O90RL&rb=news_guonei7_bbs">精华推荐</a>-->  
  <a  href=";postid=4F4BUKU200011SM9_4F6O90RL&amp;flag=0','voteForNumber_4F4BUKU200011SM9_4F6O90RL');" target="_self" >支持</a>[<span >0</span>] <a  href=";postid=4F4BUKU200011SM9_4F6O90RL','voteAgainstNumber_4F4BUKU200011SM9_4F6O90RL');" target="_self">反对</a>[<span >0</span>] 
  <a href=";">举报</a> 
            
  <span  ></span>
  
 </div>
    
    <div  >
      <div >
                  