ï»??xml version="1.0" encoding="utf-8" standalone="yes"?>国产对白在线正在播放,成人av观看,欧美日韩精品免费观看视欧美高清免费大片http://www.aygfsteel.com/kawaii/å¿«ä¹¾~–程åQŒå¼€å¿ƒç”Ÿ‹z?/description>zh-cnSat, 05 Jul 2025 20:42:41 GMTSat, 05 Jul 2025 20:42:41 GMT60CCP Review-Javascripthttp://www.aygfsteel.com/kawaii/archive/2007/11/27/163576.htmllixwlixwTue, 27 Nov 2007 15:41:00 GMThttp://www.aygfsteel.com/kawaii/archive/2007/11/27/163576.htmlhttp://www.aygfsteel.com/kawaii/comments/163576.htmlhttp://www.aygfsteel.com/kawaii/archive/2007/11/27/163576.html#Feedback0http://www.aygfsteel.com/kawaii/comments/commentRss/163576.htmlhttp://www.aygfsteel.com/kawaii/services/trackbacks/163576.html 1ã€å¯¹äºŽdiv中的input标签åQŒå¦‚æžœdivçš„style.displayå±žæ€§äØ“(f¨´)'none'åQŒé‚£ä¹ˆè°ƒç”¨input标签的focusæ–ÒŽ(gu¨©)³•在IE6.0上会(x¨¬)报错åQŒé¦–先应该让其displayå±žæ€§äØ“(f¨´)''或è€?block'å†è°ƒç”¨ï¼›
2ã€å½“HTML元素的name属性唯一时å¯ä»¥åˆ©ç”¨document.getElementById()调用获得˜q™ä¸ªå…ƒç´ åQ?br /> 3ã€å¦‚果异步æäº¤è€—时较长åQŒå¯åœ¨å¼‚æ­¥æäº¤ä¹‹å‰æ˜¾½Cºç­‰å¾…æ½Cºï¼Œåœ¨å›žè°ƒå‡½æ•îC¸­æ ÒŽ(gu¨©)®˜q”回值更新æ½Cºï¼›
4ã€åœ¨JS中function也是å¯ä»¥ä½œäØ“(f¨´)å˜é‡çš„,所以我们å¯ä»¥åœ¨è‡ªå·±ž®è£…的框架中预留回调函数供自定义使用åQŒå¦‚下é¢çš„代ç ï¼š(x¨¬)
 1 //common.js
 2 var callback = null;
 3 function commonUse(){
 4   
 5   if(typeof(callback) == "function"){
 6     callback();
 7   }
 8   
 9 }
10 
11 //self.js
12 function selfUse(){
13   
14   callback = function(){
15     //do something before
16   }
17   commonUse();
18   
19 }

5ã€JS中å¯ä»¥ä‹Éç”¨æ­£åˆ™è¡¨è¾‘Ö¼æ¥æ ¡éªŒæ•°å­—åŸŸã€æ—¥æœŸåŸŸå’ŒEMail½{‰ã€‚代ç ç¤ºä¾‹å¦‚下:(x¨¬)
校验日期的例å­ï¼š(x¨¬)
 1     function isDate(date){
 2         //å¯ÒŽ(gu¨©)—¥æœŸæ ¼å¼è¿›è¡ŒéªŒè¯?nbsp;è¦æ±‚ä¸?000-2099òq?nbsp; æ ¼å¼ä¸?nbsp;yyyy-mm-dd òq¶ä¸”å¯ä»¥æ­£å¸¸è½¬æ¢æˆæ­£¼‹®çš„æ—¥æœŸ
 3         var regex=/^(19|20)\d{2}-((0[1-9]{1})|(1[0-2]{1}))-((0[1-9]{1})|([1-2]{1}[0-9]{1})|(3[0-1]{1}))$/;
 4         
 5         if(!regex.test(date)){
 6             return false;
 7         }
 8         var arr_=date.split("-");
 9         var tmp = new Date(arr_[0], parseFloat(arr_[1])-1, parseFloat(arr_[2]));
10         if(tmp.getFullYear()!=parseFloat(arr_[0]) 
11             || tmp.getMonth()!=parseFloat(arr_[1])-1 
12             || tmp.getDate()!=parseFloat(arr_[2])){
13             return false;
14         }
15          
16          return true;
17     }
  ˜q™ç¯‡æ–‡ç« æœ‰è¯¦¾l†çš„说明åQ?a target="_blank" href="http://www.aygfsteel.com/byterat/archive/2006/12/20/89143.html">http://www.aygfsteel.com/byterat/archive/2006/12/20/89143.html
  ˜q™æœ¬ç”?sh¨´)å­ä¹¦æ˜¯è®²è§£æ­£åˆ™è¡¨è¾¾å¼çš„åQ?a target="_blank" href="http://www.aygfsteel.com/Files/kawaii/RegularExpressions.zip">http://www.aygfsteel.com/Files/kawaii/RegularExpressions.zip 
6ã€åœ¨JS¾~–ç ä¸­ï¼Œå¦‚果代ç é‡è¾ƒå¤§ï¼Œè¦æ³¨æ„防止functionåç§°é‡å¤åQŒåŒ…括直接在™åµé¢ä¸Šç¼–写的和引用外部JSæ–‡äšg的,ä¸ç„¶ä¼?x¨¬)出çŽîC¸€äº›èŽ«å奇妙的问题åQ?br /> 7ã€æ³¨æ„JS代ç ä¸­çš„函数˜q”回语å¥returnçš„ä‹É用;
8ã€å°½é‡æŠŠJS代ç å†™åœ¨å¤–部公共的文件中åQŒè€Œåœ¨™åµé¢ä¸­å¼•入,好处有:(x¨¬)a.函数å¤ç”¨åQ›b.JSæ–‡äšg¾~“å­˜åQ›c.æä¾›™åµé¢è§£æžé€Ÿåº¦ã€‚基于båQŒæˆ‘们在修改JS代ç åŽï¼Œè¦çœ‹IE的设¾|®æ˜¯å¦å°†åŽŸå…ˆçš„JSæ–‡äšg¾~“存造æˆé—®é¢˜åQ?br /> 9ã€å¯¹äºŽåŒä¸€ä¸ªé¡µé¢çš„å¤šä¸ªè¡¨å•æäº¤åQŒæˆ‘们å¯ä»¥åœ¨½W¬ä¸€ä¸ªè¡¨å•中讄¡½®ç›¸åº”çš„éšè—域åQŒåœ¨è¡¨å•æäº¤ä¹‹å‰åˆ©ç”¨JS脚本把其他表å•的数æ®è®„¡½®åˆ°ç¬¬ä¸€ä¸ªè¡¨å•çš„éšè—域中åQ?br /> 10ã€å¯¹äºŽå¼‚步校验的文本框,我们一般设¾|®è§¦å‘äº‹ä»¶äØ“(f¨´)onblurè€Œä¸æ˜¯onchange或者onpropertychangeåQŒä»¥å‡å°‘客户端和æœåŠ¡å™¨çš„äº¤äº’‹Æ¡æ•°åQŒä½†åº”该注æ„如果˜q™ä¸ªæ–‡æœ¬æ¡†æœ€åˆæ²¡æœ‰èŽ·å¾—ç„¦ç‚¹ï¼Œé‚£ä¹ˆonblurž®×ƒ¸ä¼?x¨¬)触å‘,å¯ä»¥å…ˆè°ƒç”¨ä»¥ä¸‹onfocusåQŒå†è°ƒç”¨onblur手动触å‘åQ?br /> 11ã€JS中ä¸å­˜åœ¨trim()函数åQŒè‡ªå®šä¹‰å¦‚下åQ?br />
 1 //JS去除首尾½Iºæ ¼åQˆåŒVBSçš„Trim)
 2     function trim(inputString) {   
 3         if (typeof inputString != "string") {
 4             return inputString; 
 5         }
 6         var retValue = inputString;
 7         var ch = retValue.substring(01);
 8         while (ch == " ") {
 9                //‹‚€(g¨¨)查字½W¦ä¸²å¼€å§‹éƒ¨åˆ†çš„½Iºæ ¼
10             retValue = retValue.substring(1, retValue.length);
11             ch = retValue.substring(01);
12         }
13         ch = retValue.substring(retValue.length-1, retValue.length);
14         while (ch == " ") {
15             //‹‚€(g¨¨)查字½W¦ä¸²¾l“æŸéƒ¨åˆ†çš„空æ ?/span>
16             retValue = retValue.substring(0, retValue.length-1);
17             ch = retValue.substring(retValue.length-1, retValue.length);
18         }
19         while (retValue.indexOf("  "!= -1) {
20             //ž®†æ–‡å­—中间多个相˜qžçš„½Iºæ ¼å˜äØ“(f¨´)一个空æ ?/span>
21             retValue = retValue.substring(0, retValue.indexOf("  ")) 
22                 + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
23         }
24         return retValue;
25     }
12ã€JS中显½Cºæ¨¡å¼çª—å£ï¼Œä»£ç å¦‚下åQ?br />
 1 function showMyDialog(){
 2   var dialogProperty = 'dialogWidth:800px;dialogHeight:600px;status:no';
 3   var windowProperty = "height=800,width=800,status=no,toolbar=no,menubar=yes,location=yes,resizable=yes,scrollbars=yes";
 4 
 5   var url = "SomeAction.do?id="+id+"&flag=true";
 6   var returnVal = window.showModalDialog(url,"", dialogProperty);
 7   if(typeof(returnVal) == "undefined"){
 8     return;
 9   }
10   if(returnVal !=  ""){
11     //do something   
12   }
13 }
14 
在新打开的模å¼çª—å£ä¸­åQŒæˆ‘们通过window.returnValue讄¡½®˜q”回å€û|¼Œç„¶åŽåœ¨çˆ¶™åµé¢ä¸­æˆ‘们通过returnValå¯ä»¥æ‹¿åˆ°˜q”回倹{€?br />

]]>
DB2常用命ä×o(h¨´)http://www.aygfsteel.com/kawaii/archive/2007/04/27/113978.htmllixwlixwFri, 27 Apr 2007 00:54:00 GMThttp://www.aygfsteel.com/kawaii/archive/2007/04/27/113978.htmlhttp://www.aygfsteel.com/kawaii/comments/113978.htmlhttp://www.aygfsteel.com/kawaii/archive/2007/04/27/113978.html#Feedback0http://www.aygfsteel.com/kawaii/comments/commentRss/113978.htmlhttp://www.aygfsteel.com/kawaii/services/trackbacks/113978.html  db2start   
  2åQ?åœæ­¢æ•°æ®åº?nbsp;  
  db2stop   
  3åQ?˜qžæŽ¥æ•°æ®åº?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  4åQ?è¯ÀL•°æ®åº“½Ž¡ç†½E‹åºé…ç½®   
  db2   get   dbm   cfg   
  5åQ?写数æ®åº“½Ž¡ç†½E‹åºé…ç½®   
  db2   update   dbm   cfg   using   傿•°å?nbsp;  傿•°å€?nbsp;  
  6åQ?è¯ÀL•°æ®åº“的酾|?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   get   db   cfg   for   o_yd   
  7åQ?写数æ®åº“的酾|?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   update   db   cfg   for   o_yd   using   傿•°å?nbsp;  傿•°å€?nbsp;  
  8åQ?关闭所有应用连æŽ?nbsp;  
  db2   force   application   all   
  db2   force   application   ID1,ID2,,,Idn   MODE   ASYNC   
  (db2   list   application   for   db   o_yd   show   detail)   
  9åQ?备䆾数æ®åº?nbsp;  
  db2   force   application   all   
  db2   backup   db   o_yd   to   d:   
  (db2   initialize   tape   on   \\.\tape0)   
  (db2   rewind   tape   on   \\.\tape0)   
  db2   backup   db   o_yd   to   \\.\tape0   
  10åQ?æ¢å¤æ•°æ®åº?nbsp;  
  db2   restore   db   o_yd   from   d:   to   d:     
  db2   restore   db   o_yd   from   \\.\tape0   to   d:   
  11åQ?¾l‘定存储˜q‡ç¨‹   
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   bind   c:\dfplus.bnd   
  拯‚´å­˜å‚¨˜q‡ç¨‹åˆ°æœåŠ¡å™¨ä¸Šçš„C:\sqllib\function目录ä¸?nbsp;  
  12åQ?æ•´ç†è¡?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   reorg   table   ydd   
  db2   runstats   on   table   ydd   with   distribution   and   indexes   all     
  13åQ?导出表数æ?nbsp; 
  db2   export   to   c:\sw.txt   of   del   select   *   from   dftz  
  db2   export   to   c:\sw.ixf   of   ixf   select   *   from   dftz  
  14åQ?导入表数æ?nbsp; 
  db2   import   from   c:\sw.txt   of   del   insert   into   ylbx.czyxx  
  db2   import   to   c:\sw.txt   of   del   commitcount   5000   messages       c:\dftz.msg   insert   into   dftz  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   messages   c:\dftz.msg   insert   into   dftz  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   insert   into   dftz  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   insert_update   into   dftz  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   replace   into   dftz  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   create   into   dftz       (ä»…IXF)  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   replace_create   into   dftz     (ä»…IXF)  
  15åQ?æ‰§è¡Œä¸€ä¸ªæ‰¹å¤„ç†æ–‡äšg  
  db2   –tf   æ‰¹å¤„ç†æ–‡ä»¶å  
  åQˆæ–‡ä»¶ä¸­æ¯ä¸€æ¡å‘½ä»¤ç”¨   åQ›ç»“æŸï¼‰  
  16åQ?è‡ªåŠ¨ç”Ÿæˆæ‰¹å¤„ç†æ–‡ä»?nbsp; 
  建文本文ä»Óž¼š(x¨¬)temp.sql  
  select   'runstats   on   table   DB2.'   ||   tabname   ||   '   with   distribution   and   detailed   indexes   all;'   from   syscat.tables   where   tabschema='DB2'   and   type='T';
  db2   –tf   temp.sql>runstats.sql  
  17åQ?自动生æˆå»ø™¡¨åQˆè§†å›¾ï¼‰è¯­å¥  
  在æœåŠ¡å™¨ä¸Šï¼š(x¨¬)C:\sqllib\misc目录ä¸?nbsp; 
  db2   connect   to   o_yd   user   db2   using   pwd  
  db2look   –d   o_yd   –u   db2   –e   –p   –c   c:\o_yd.txt     
  db2look   -d   lys   -e   -a   -x   -i   db2admin   -o   c:\aa.txt  
  18åQ?其他命ä×o(h¨´)  
  grant   dbadm   on   database   to   user   bb   
  19.    select   *   from   czyxx   fetch   first   1   rows   only  
  20.    db2look   –d   lys   –u   db2admin   –w   –asd   –a   –e   –o   c:\mytable.txt   



]]>
log4j½Ž€ä»?/title><link>http://www.aygfsteel.com/kawaii/archive/2007/04/25/113581.html</link><dc:creator>lixw</dc:creator><author>lixw</author><pubDate>Wed, 25 Apr 2007 09:34:00 GMT</pubDate><guid>http://www.aygfsteel.com/kawaii/archive/2007/04/25/113581.html</guid><wfw:comment>http://www.aygfsteel.com/kawaii/comments/113581.html</wfw:comment><comments>http://www.aygfsteel.com/kawaii/archive/2007/04/25/113581.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/kawaii/comments/commentRss/113581.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/kawaii/services/trackbacks/113581.html</trackback:ping><description><![CDATA[1.在应用程åºä¸­ä½¿ç”¨æ—¥å¿—的三个目的:(x¨¬)<br>应用½E‹åºä¸­æ·»åŠ æ—¥å¿—çš„ä¸‰ä¸ªç›®çš„åQšç›‘视代ç ä¸­å˜é‡çš„å˜åŒ–情况,周期性的记录到文件中供其他应用进行统计分æžå·¥ä½œï¼›<br>跟踪代砘q行时轨˜q¹ï¼Œä½œäØ“(f¨´)æ—¥åŽå®¡è®¡çš„便®ï¼›<br>担当集æˆå¼€å‘çŽ¯å¢ƒä¸­çš„è°ƒè¯•å™¨çš„ä½œç”¨ï¼Œå‘æ–‡ä»¶æˆ–æŽ§åˆ¶å°æ‰“åîC»£ç çš„调试信æ¯ã€?br><br>2.log4jç”׃¸‰ä¸ªé‡è¦çš„¾l„äšgæž„æˆåQšæ—¥å¿—ä¿¡æ¯çš„优先¾U§ï¼Œæ—¥å¿—ä¿¡æ¯çš„输出目的地åQŒæ—¥å¿—ä¿¡æ¯çš„输出格å¼ã€?br>使用Javaç‰ÒŽ(gu¨©)€§æ–‡ä»¶åšä¸ºé…¾|®æ–‡ä»¶çš„æ–ÒŽ(gu¨©)³•åQ?br>2.1. é…置根LoggeråQŒå…¶è¯­æ³•为:(x¨¬)<br>log4j.rootLogger = [ level ] , appenderName, appenderName, ...<br>其中åQŒlevel 是日志记录的优先¾U§ï¼Œåˆ†äØ“(f¨´)OFFã€FATALã€ERRORã€WARNã€INFOã€DEBUGã€ALL或者æ?zh¨¨n)¨å®šä¹‰çš„çñ”别ã€?br>Log4j廸™®®åªä‹É用四个çñ”别,优先¾U§ä»Žé«˜åˆ°ä½Žåˆ†åˆ«æ˜¯ERRORã€WARNã€INFOã€DEBUGã€?br>通过在这里定义的¾U§åˆ«åQŒæ?zh¨¨n)¨å¯ä»¥æŽ§åˆ¶åˆ°åº”用程åºä¸­ç›¸åº”¾U§åˆ«çš„æ—¥å¿—ä¿¡æ¯çš„开兟ë€?br>比如在这里定义了INFO¾U§åˆ«åQŒåˆ™åº”用½E‹åºä¸­æ‰€æœ‰DEBUG¾U§åˆ«çš„æ—¥å¿—ä¿¡æ¯å°†ä¸è¢«æ‰“å°å‡ºæ¥ã€?br>appenderNamež®±æ˜¯æŒ‡å®šæ—¥å¿—ä¿¡æ¯è¾“出到哪个地æ–V€‚æ?zh¨¨n)¨å¯ä»¥åŒæ—¶æŒ‡å®šå¤šä¸ªè¾“出目的地ã€?br>2.2. é…置日志信æ¯è¾“出目的地AppenderåQŒå…¶è¯­æ³•ä¸?br>log4j.appender.appenderName = fully.qualified.name.of.appender.class<br>log4j.appender.appenderName.option1 = value1<br>...<br>log4j.appender.appenderName.option = valueN<br><br>其中åQŒLog4jæä¾›çš„appender有以下几¿U:(x¨¬)<br>org.apache.log4j.ConsoleAppenderåQˆæŽ§åˆ¶å°åQ‰ï¼Œ<br>org.apache.log4j.FileAppenderåQˆæ–‡ä»Óž¼‰åQ?br>org.apache.log4j.DailyRollingFileAppenderåQˆæ¯å¤©äñ”生一个日志文ä»Óž¼‰åQ?br>org.apache.log4j.RollingFileAppenderåQˆæ–‡ä»¶å¤§ž®åˆ°è¾¾æŒ‡å®šå°ºå¯¸çš„æ—¶å€™äñ”生一个新的文ä»Óž¼‰åQ?br>org.apache.log4j.WriterAppenderåQˆå°†æ—¥å¿—ä¿¡æ¯ä»¥æµæ ¼å¼å‘é€åˆ°ä»ÀL„指定的地方)<br><br>2.3. é…置日志信æ¯çš„æ ¼å¼ï¼ˆå¸ƒå±€åQ‰ï¼Œå…¶è¯­æ³•䨓(f¨´)åQ?br>log4j.appender.appenderName.layout = fully.qualified.name.of.layout.class<br>log4j.appender.appenderName.layout.option1 = value1<br>...<br>log4j.appender.appenderName.layout.option = valueN<br><br>其中åQŒLog4jæä¾›çš„layout有以下几¿U:(x¨¬)<br>org.apache.log4j.HTMLLayoutåQˆä»¥HTML表格形å¼å¸ƒå±€åQ‰ï¼Œ<br>org.apache.log4j.PatternLayoutåQˆå¯ä»¥çµ‹zÕdœ°æŒ‡å®šå¸ƒå±€æ¨¡å¼åQ‰ï¼Œ<br>org.apache.log4j.SimpleLayoutåQˆåŒ…嫿—¥å¿—ä¿¡æ¯çš„¾U§åˆ«å’Œä¿¡æ¯å­—½W¦ä¸²åQ‰ï¼Œ<br>org.apache.log4j.TTCCLayoutåQˆåŒ…嫿—¥å¿—äñ”生的旉™—´ã€çº¿½E‹ã€ç±»åˆ«ç­‰½{‰ä¿¡æ¯ï¼‰<br><br>3.在代ç ä¸­ä½¿ç”¨Log4j,下颞®†è®²˜q°åœ¨½E‹åºä»£ç ä¸­æ€Žæ ·ä½¿ç”¨Log4jã€?br><br>3.1.得到记录å™?br>使用Log4jåQŒç¬¬ä¸€æ­¥å°±æ˜¯èŽ·å–æ—¥å¿—记录器åQŒè¿™ä¸ªè®°å½•器ž®†è´Ÿè´£æŽ§åˆ¶æ—¥å¿—ä¿¡æ¯ã€‚其语法为:(x¨¬)<br>public static Logger getLogger( String name)åQ?br>通过指定的å字获得记录器åQŒå¦‚果必è¦çš„è¯ï¼Œåˆ™äØ“(f¨´)˜q™ä¸ªå字创å¾ä¸€ä¸ªæ–°çš„记录器。Nameä¸€èˆ¬å–æœ¬ç±»çš„å字,比如åQ?br>static Logger logger = Logger.getLogger ( ServerWithLog4j.class.getName () ) ;<br><br>3.2.è¯Õd–é…置文äšg<br>当获得了日志记录器之åŽï¼Œ½W¬äºŒæ­¥å°†é…ç½®Log4j环境åQŒå…¶è¯­æ³•为:(x¨¬)<br>BasicConfigurator.configure ()åQ?自动快速地使用¾~ºçœLog4j环境ã€?br>PropertyConfigurator.configure ( String configFilename) åQšè¯»å–ä‹É用Java的特性文件编写的é…置文äšgã€?br>DOMConfigurator.configure ( String filename ) åQšè¯»å–XMLå½¢å¼çš„é…¾|®æ–‡ä»¶ã€?br><br>3.3.æ’入记录信æ¯åQˆæ ¼å¼åŒ–日志信æ¯åQ?br>å½“ä¸Šä¸¤ä¸ªå¿…è¦æ­¥éª¤æ‰§è¡Œå®Œæ¯•åQŒæ?zh¨¨n)¨ž®±å¯ä»¥è½»æ‘Öœ°ä½¿ç”¨ä¸åŒä¼˜å…ˆ¾U§åˆ«çš„æ—¥å¿—è®°å½•è¯­å¥æ’入到æ‚(zh¨¨n)¨æƒ³è®°å½•日志的ä“Q何地方,其语法如下:(x¨¬)<br>Logger.debug ( Object message ) ;<br>Logger.info ( Object message ) ;<br>Logger.warn ( Object message ) ;<br>Logger.error ( Object message ) ; <br><br>一个酾|®çš„例å­:<br>log4j.rootLogger=INFO, stdout ,R <br>log4j.appender.stdout.Threshold=ERROR <br>log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n log4j.appender.R.Threshold=INFO <br>log4j.appender.R=org.apache.log4j.DailyRollingFileAppender <br>log4j.appender.R.File=c:/log.log <br>log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n <img src ="http://www.aygfsteel.com/kawaii/aggbug/113581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/kawaii/" target="_blank">lixw</a> 2007-04-25 17:34 <a href="http://www.aygfsteel.com/kawaii/archive/2007/04/25/113581.html#Feedback" target="_blank" style="text-decoration:none;">å‘表评论</a></div>]]></description></item><item><title>多线½E‹ç›‘嬿–‡ä»¶æ”¹åŠ?/title><link>http://www.aygfsteel.com/kawaii/archive/2007/02/08/98668.html</link><dc:creator>lixw</dc:creator><author>lixw</author><pubDate>Thu, 08 Feb 2007 02:07:00 GMT</pubDate><guid>http://www.aygfsteel.com/kawaii/archive/2007/02/08/98668.html</guid><wfw:comment>http://www.aygfsteel.com/kawaii/comments/98668.html</wfw:comment><comments>http://www.aygfsteel.com/kawaii/archive/2007/02/08/98668.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/kawaii/comments/commentRss/98668.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/kawaii/services/trackbacks/98668.html</trackback:ping><description><![CDATA[一¿U比较简陋的æ–ÒŽ(gu¨©)³•åQ?br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">ActionListener taskPerformer </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ActionListener() {<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> actionPerformed(ActionEvent evt) {<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">                log.info(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">monitor is running at </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> java.util.Date());<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">                String configfile </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)getServletContext().getAttribute(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">configfile</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(configfile </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&&</span><span style="color: rgb(0, 0, 0);"> configfile.length()</span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">){<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">                    </span><span style="color: rgb(0, 0, 255);">try</span><span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">                        File file </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> File(configfile);<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">                        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(file.lastModified() </span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"> lastModifyTime){<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">                            lastModifyTime </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> file.lastModified();<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">                            loadProp();<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">                        }<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">                    }</span><span style="color: rgb(0, 0, 255);">catch</span><span style="color: rgb(0, 0, 0);">(Exception e){<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">                        log.error(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">construct file:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> configfile </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> exception</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">                        e.printStackTrace();<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">                    }<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">                }<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">            }<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);"> };<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">20</span>  <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">å¯åŠ¨ç›‘å¬¾U¿ç¨‹</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Timer(delay, taskPerformer).start();</span></div><br /><br />æ¥è‡ªgeosoft.no的解å†Ïx–¹æ³•:(x¨¬)<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.File;<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 128, 0);"> * Interface for listening to disk file changes.<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 128, 0);"> * </span><span style="color: rgb(128, 128, 128);">@see</span><span style="color: rgb(0, 128, 0);"> FileMonitor<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);"> * <br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 128, 0);"> * </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 128, 0);"> </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);">   <br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);"> FileListener<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 128, 0);">   * Called when one of the monitored files are created, deleted<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 128, 0);">   * or modified.<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> file  File which has been changed.<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> fileChanged (File file);<br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">}</span></div><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">  1</span> <span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.util.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">  2</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.io.File;<br /></span><span style="color: rgb(0, 128, 128);">  3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> java.lang.ref.WeakReference;<br /></span><span style="color: rgb(0, 128, 128);">  4</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">  6</span> <span style="color: rgb(0, 128, 0);"> * Class for monitoring changes in disk files.<br /></span><span style="color: rgb(0, 128, 128);">  7</span> <span style="color: rgb(0, 128, 0);"> * Usage:<br /></span><span style="color: rgb(0, 128, 128);">  8</span> <span style="color: rgb(0, 128, 0);"> *<br /></span><span style="color: rgb(0, 128, 128);">  9</span> <span style="color: rgb(0, 128, 0);"> *    1. Implement the FileListener interface.<br /></span><span style="color: rgb(0, 128, 128);"> 10</span> <span style="color: rgb(0, 128, 0);"> *    2. Create a FileMonitor instance.<br /></span><span style="color: rgb(0, 128, 128);"> 11</span> <span style="color: rgb(0, 128, 0);"> *    3. Add the file(s)/directory(ies) to listen for.<br /></span><span style="color: rgb(0, 128, 128);"> 12</span> <span style="color: rgb(0, 128, 0);"> *<br /></span><span style="color: rgb(0, 128, 128);"> 13</span> <span style="color: rgb(0, 128, 0);"> * fileChanged() will be called when a monitored file is created,<br /></span><span style="color: rgb(0, 128, 128);"> 14</span> <span style="color: rgb(0, 128, 0);"> * deleted or its modified time changes.<br /></span><span style="color: rgb(0, 128, 128);"> 15</span> <span style="color: rgb(0, 128, 0);"> *<br /></span><span style="color: rgb(0, 128, 128);"> 16</span> <span style="color: rgb(0, 128, 0);"> * </span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);"> <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a><br /></span><span style="color: rgb(0, 128, 128);"> 17</span> <span style="color: rgb(0, 128, 0);"> </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);">   <br /></span><span style="color: rgb(0, 128, 128);"> 18</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> FileMonitor<br /></span><span style="color: rgb(0, 128, 128);"> 19</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 20</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> Timer       timer_;<br /></span><span style="color: rgb(0, 128, 128);"> 21</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> HashMap     files_;       </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> File -> Long</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 22</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> Collection  listeners_;   </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> of WeakReference(FileListener)</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 23</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">   <br /></span><span style="color: rgb(0, 128, 128);"> 24</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 25</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 26</span> <span style="color: rgb(0, 128, 0);">   * Create a file monitor instance with specified polling interval.<br /></span><span style="color: rgb(0, 128, 128);"> 27</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);"> 28</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> pollingInterval  Polling interval in milli seconds.<br /></span><span style="color: rgb(0, 128, 128);"> 29</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 30</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> FileMonitor (</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);"> pollingInterval)<br /></span><span style="color: rgb(0, 128, 128);"> 31</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 32</span> <span style="color: rgb(0, 0, 0);">    files_     </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> HashMap();<br /></span><span style="color: rgb(0, 128, 128);"> 33</span> <span style="color: rgb(0, 0, 0);">    listeners_ </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ArrayList();<br /></span><span style="color: rgb(0, 128, 128);"> 34</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 35</span> <span style="color: rgb(0, 0, 0);">    timer_ </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Timer (</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 36</span> <span style="color: rgb(0, 0, 0);">    timer_.schedule (</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileMonitorNotifier(), </span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">, pollingInterval);<br /></span><span style="color: rgb(0, 128, 128);"> 37</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);"> 38</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 39</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 40</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);"> 41</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 42</span> <span style="color: rgb(0, 128, 0);">   * Stop the file monitor polling.<br /></span><span style="color: rgb(0, 128, 128);"> 43</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 44</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> stop()<br /></span><span style="color: rgb(0, 128, 128);"> 45</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 46</span> <span style="color: rgb(0, 0, 0);">    timer_.cancel();<br /></span><span style="color: rgb(0, 128, 128);"> 47</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);"> 48</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);"> 49</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 50</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 51</span> <span style="color: rgb(0, 128, 0);">   * Add file to listen for. File may be any java.io.File (including a<br /></span><span style="color: rgb(0, 128, 128);"> 52</span> <span style="color: rgb(0, 128, 0);">   * directory) and may well be a non-existing file in the case where the<br /></span><span style="color: rgb(0, 128, 128);"> 53</span> <span style="color: rgb(0, 128, 0);">   * creating of the file is to be trepped.<br /></span><span style="color: rgb(0, 128, 128);"> 54</span> <span style="color: rgb(0, 128, 0);">   * <p><br /></span><span style="color: rgb(0, 128, 128);"> 55</span> <span style="color: rgb(0, 128, 0);">   * More than one file can be listened for. When the specified file is<br /></span><span style="color: rgb(0, 128, 128);"> 56</span> <span style="color: rgb(0, 128, 0);">   * created, modified or deleted, listeners are notified.<br /></span><span style="color: rgb(0, 128, 128);"> 57</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);"> 58</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> file  File to listen for.<br /></span><span style="color: rgb(0, 128, 128);"> 59</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 60</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> addFile (File file)<br /></span><span style="color: rgb(0, 128, 128);"> 61</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 62</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">files_.containsKey (file)) {<br /></span><span style="color: rgb(0, 128, 128);"> 63</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);"> modifiedTime </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> file.exists() </span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"> file.lastModified() : </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 64</span> <span style="color: rgb(0, 0, 0);">      files_.put (file, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Long (modifiedTime));<br /></span><span style="color: rgb(0, 128, 128);"> 65</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 66</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);"> 67</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 68</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);"> 69</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 70</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 71</span> <span style="color: rgb(0, 128, 0);">   * Remove specified file for listening.<br /></span><span style="color: rgb(0, 128, 128);"> 72</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);"> 73</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> file  File to remove.<br /></span><span style="color: rgb(0, 128, 128);"> 74</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 75</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> removeFile (File file)<br /></span><span style="color: rgb(0, 128, 128);"> 76</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 77</span> <span style="color: rgb(0, 0, 0);">    files_.remove (file);<br /></span><span style="color: rgb(0, 128, 128);"> 78</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);"> 79</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 80</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 81</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);"> 82</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 83</span> <span style="color: rgb(0, 128, 0);">   * Add listener to this file monitor.<br /></span><span style="color: rgb(0, 128, 128);"> 84</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);"> 85</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> fileListener  Listener to add.<br /></span><span style="color: rgb(0, 128, 128);"> 86</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 87</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> addListener (FileListener fileListener)<br /></span><span style="color: rgb(0, 128, 128);"> 88</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 89</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Don't add if its already there</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 90</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (Iterator i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> listeners_.iterator(); i.hasNext(); ) {<br /></span><span style="color: rgb(0, 128, 128);"> 91</span> <span style="color: rgb(0, 0, 0);">      WeakReference reference </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (WeakReference) i.next();<br /></span><span style="color: rgb(0, 128, 128);"> 92</span> <span style="color: rgb(0, 0, 0);">      FileListener listener </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (FileListener) reference.get();<br /></span><span style="color: rgb(0, 128, 128);"> 93</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (listener </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> fileListener)<br /></span><span style="color: rgb(0, 128, 128);"> 94</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);"> 95</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);"> 96</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 97</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Use WeakReference to avoid memory leak if this becomes the<br /></span><span style="color: rgb(0, 128, 128);"> 98</span> <span style="color: rgb(0, 128, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> sole reference to the object.</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 99</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    listeners_.add (</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> WeakReference (fileListener));<br /></span><span style="color: rgb(0, 128, 128);">100</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">101</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">102</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">103</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);">104</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">105</span> <span style="color: rgb(0, 128, 0);">   * Remove listener from this file monitor.<br /></span><span style="color: rgb(0, 128, 128);">106</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);">107</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> fileListener  Listener to remove.<br /></span><span style="color: rgb(0, 128, 128);">108</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">109</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> removeListener (FileListener fileListener)<br /></span><span style="color: rgb(0, 128, 128);">110</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);">111</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (Iterator i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> listeners_.iterator(); i.hasNext(); ) {<br /></span><span style="color: rgb(0, 128, 128);">112</span> <span style="color: rgb(0, 0, 0);">      WeakReference reference </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (WeakReference) i.next();<br /></span><span style="color: rgb(0, 128, 128);">113</span> <span style="color: rgb(0, 0, 0);">      FileListener listener </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (FileListener) reference.get();<br /></span><span style="color: rgb(0, 128, 128);">114</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (listener </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> fileListener) {<br /></span><span style="color: rgb(0, 128, 128);">115</span> <span style="color: rgb(0, 0, 0);">        i.remove();<br /></span><span style="color: rgb(0, 128, 128);">116</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">break</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">117</span> <span style="color: rgb(0, 0, 0);">      }<br /></span><span style="color: rgb(0, 128, 128);">118</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">119</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">120</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">121</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">122</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);">123</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">124</span> <span style="color: rgb(0, 128, 0);">   * This is the timer thread which is executed every n milliseconds<br /></span><span style="color: rgb(0, 128, 128);">125</span> <span style="color: rgb(0, 128, 0);">   * according to the setting of the file monitor. It investigates the<br /></span><span style="color: rgb(0, 128, 128);">126</span> <span style="color: rgb(0, 128, 0);">   * file in question and notify listeners if changed.<br /></span><span style="color: rgb(0, 128, 128);">127</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">128</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> FileMonitorNotifier </span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);"> TimerTask<br /></span><span style="color: rgb(0, 128, 128);">129</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);">130</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> run()<br /></span><span style="color: rgb(0, 128, 128);">131</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">132</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Loop over the registered files and see which have changed.<br /></span><span style="color: rgb(0, 128, 128);">133</span> <span style="color: rgb(0, 128, 0);">      </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Use a copy of the list in case listener wants to alter the<br /></span><span style="color: rgb(0, 128, 128);">134</span> <span style="color: rgb(0, 128, 0);">      </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> list within its fileChanged method.</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">135</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">      Collection files </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> ArrayList (files_.keySet());<br /></span><span style="color: rgb(0, 128, 128);">136</span> <span style="color: rgb(0, 0, 0);">      <br /></span><span style="color: rgb(0, 128, 128);">137</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (Iterator i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> files.iterator(); i.hasNext(); ) {<br /></span><span style="color: rgb(0, 128, 128);">138</span> <span style="color: rgb(0, 0, 0);">        File file </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (File) i.next();<br /></span><span style="color: rgb(0, 128, 128);">139</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);"> lastModifiedTime </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ((Long) files_.get (file)).longValue();<br /></span><span style="color: rgb(0, 128, 128);">140</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);"> newModifiedTime  </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> file.exists() </span><span style="color: rgb(0, 0, 0);">?</span><span style="color: rgb(0, 0, 0);"> file.lastModified() : </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 128, 128);">141</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">142</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Chek if file has changed</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">143</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (newModifiedTime </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> lastModifiedTime) {<br /></span><span style="color: rgb(0, 128, 128);">144</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">145</span> <span style="color: rgb(0, 0, 0);">          </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Register new modified time</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">146</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">          files_.put (file, </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Long (newModifiedTime));<br /></span><span style="color: rgb(0, 128, 128);">147</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">148</span> <span style="color: rgb(0, 0, 0);">          </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Notify listeners</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">149</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">          </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (Iterator j </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> listeners_.iterator(); j.hasNext(); ) {<br /></span><span style="color: rgb(0, 128, 128);">150</span> <span style="color: rgb(0, 0, 0);">            WeakReference reference </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (WeakReference) j.next();<br /></span><span style="color: rgb(0, 128, 128);">151</span> <span style="color: rgb(0, 0, 0);">            FileListener listener </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (FileListener) reference.get();<br /></span><span style="color: rgb(0, 128, 128);">152</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">153</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Remove from list if the back-end object has been GC'd</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">154</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (listener </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br /></span><span style="color: rgb(0, 128, 128);">155</span> <span style="color: rgb(0, 0, 0);">              j.remove();<br /></span><span style="color: rgb(0, 128, 128);">156</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">157</span> <span style="color: rgb(0, 0, 0);">              listener.fileChanged (file);<br /></span><span style="color: rgb(0, 128, 128);">158</span> <span style="color: rgb(0, 0, 0);">          }<br /></span><span style="color: rgb(0, 128, 128);">159</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">160</span> <span style="color: rgb(0, 0, 0);">      }<br /></span><span style="color: rgb(0, 128, 128);">161</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">162</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">163</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">164</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">165</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">166</span> <span style="color: rgb(0, 128, 0);">   * Test this class.<br /></span><span style="color: rgb(0, 128, 128);">167</span> <span style="color: rgb(0, 128, 0);">   * <br /></span><span style="color: rgb(0, 128, 128);">168</span> <span style="color: rgb(0, 128, 0);">   * </span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);"> args  Not used.<br /></span><span style="color: rgb(0, 128, 128);">169</span> <span style="color: rgb(0, 128, 0);">   </span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">170</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main (String args[])<br /></span><span style="color: rgb(0, 128, 128);">171</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);">172</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Create the monitor</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">173</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    FileMonitor monitor </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileMonitor (</span><span style="color: rgb(0, 0, 0);">1000</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">174</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">175</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Add some files to listen for</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">176</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    monitor.addFile (</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> File (</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">D:\\myjava\\JCreatorWorkspace\\FileMonitor\\test.txt</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /></span><span style="color: rgb(0, 128, 128);">177</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">178</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Add a dummy listener</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">179</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    monitor.addListener (monitor.</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> TestListener());<br /></span><span style="color: rgb(0, 128, 128);">180</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">181</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Avoid program exit</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">182</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">while</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">) ;<br /></span><span style="color: rgb(0, 128, 128);">183</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">184</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">185</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);">186</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> TestListener<br /></span><span style="color: rgb(0, 128, 128);">187</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">implements</span><span style="color: rgb(0, 0, 0);"> FileListener<br /></span><span style="color: rgb(0, 128, 128);">188</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);">189</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> fileChanged (File file)<br /></span><span style="color: rgb(0, 128, 128);">190</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">191</span> <span style="color: rgb(0, 0, 0);">      System.out.println (</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">File [</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> file.getName() </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] changed At:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> java.util.Date());<br /></span><span style="color: rgb(0, 128, 128);">192</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">193</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">194</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">195</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">196</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">197</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><img src ="http://www.aygfsteel.com/kawaii/aggbug/98668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/kawaii/" target="_blank">lixw</a> 2007-02-08 10:07 <a href="http://www.aygfsteel.com/kawaii/archive/2007/02/08/98668.html#Feedback" target="_blank" style="text-decoration:none;">å‘表评论</a></div>]]></description></item><item><title>æ ÒŽ(gu¨©)®ä¸åŒLocale倯D¯»å–ä¸åŒçš„Propertiesé…置文äšghttp://www.aygfsteel.com/kawaii/archive/2007/02/08/98652.htmllixwlixwThu, 08 Feb 2007 01:43:00 GMThttp://www.aygfsteel.com/kawaii/archive/2007/02/08/98652.htmlhttp://www.aygfsteel.com/kawaii/comments/98652.htmlhttp://www.aygfsteel.com/kawaii/archive/2007/02/08/98652.html#Feedback0http://www.aygfsteel.com/kawaii/comments/commentRss/98652.htmlhttp://www.aygfsteel.com/kawaii/services/trackbacks/98652.html
1 //file may be named basename_locale.properties
2 ResourceBundle bundle = ResourceBundle.getBundle("basename");
3 // Enumerate contents of resource bundle
4 //The next two lines should be in one line.
5 for (Enumeration props = bundle.getKeys();props.hasMoreElements(); ) {
6     String key = (String)props.nextElement();
7     process(key, bundle.getObject(key));
8 }



]]>
Ö÷Õ¾Ö©Öë³ØÄ£°å£º Û·ÉÆÏØ| ˫ѼɽÊÐ| ¹ãµÂÏØ| ¶¼À¼ÏØ| ·ÊÎ÷ÏØ| ×ÊÔ´ÏØ| Î÷ÄþÊÐ| ãòÏªÏØ| ãä½­ÊÐ| µ±Í¿ÏØ| ¸ßÒØÏØ| °ÍÖÐÊÐ| ¶«Æ½ÏØ| Îä°²ÊÐ| ÓåÖÐÇø| ÒËÖÝÊÐ| ɳÍåÏØ| ×ÊÖÐÏØ| ÁÙ²×ÊÐ| ´ó³ÇÏØ| ¹ÌÑôÏØ| ÇåÐÂÏØ| ±Ï½ÚÊÐ| Ô£ÃñÏØ| ʯÊ×ÊÐ| ÃÉÉ½ÏØ| ½ðºþÏØ| ¾¸½­ÊÐ| ÁÙãðÏØ| ÃÚÑôÏØ| ä»Ë®ÏØ| ¿ÑÀûÏØ| ÆëÆë¹þ¶ûÊÐ| ¸£ÖÝÊÐ| µÂ²ýÏØ| ¸·ÄþÏØ| ÏÌ·áÏØ| ººÖÐÊÐ| ÕþºÍÏØ| ¼ªÊ×ÊÐ| ¾²ÄþÏØ|