锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久久久尹人综合网亚洲,亚洲熟伦熟女新五十路熟妇,亚洲av永久无码精品网址http://www.tkk7.com/kawaii/蹇箰緙栫▼錛屽紑蹇冪敓媧?/description>zh-cnSat, 10 May 2025 10:35:21 GMTSat, 10 May 2025 10:35:21 GMT60CCP Review-Javascripthttp://www.tkk7.com/kawaii/archive/2007/11/27/163576.htmllixwlixwTue, 27 Nov 2007 15:41:00 GMThttp://www.tkk7.com/kawaii/archive/2007/11/27/163576.htmlhttp://www.tkk7.com/kawaii/comments/163576.htmlhttp://www.tkk7.com/kawaii/archive/2007/11/27/163576.html#Feedback0http://www.tkk7.com/kawaii/comments/commentRss/163576.htmlhttp://www.tkk7.com/kawaii/services/trackbacks/163576.html 1銆佸浜巇iv涓殑input鏍囩錛屽鏋渄iv鐨剆tyle.display灞炴т負'none'錛岄偅涔堣皟鐢╥nput鏍囩鐨刦ocus鏂規硶鍦↖E6.0涓婁細鎶ラ敊錛岄鍏堝簲璇ヨ鍏禿isplay灞炴т負''鎴栬?block'鍐嶈皟鐢紱
2銆佸綋HTML鍏冪礌鐨刵ame灞炴у敮涓鏃跺彲浠ュ埄鐢╠ocument.getElementById()璋冪敤鑾峰緱榪欎釜鍏冪礌錛?br /> 3銆佸鏋滃紓姝ユ彁浜よ楁椂杈冮暱錛屽彲鍦ㄥ紓姝ユ彁浜や箣鍓嶆樉紺虹瓑寰呮彁紺猴紝鍦ㄥ洖璋冨嚱鏁頒腑鏍規嵁榪斿洖鍊兼洿鏂版彁紺猴紱
4銆佸湪JS涓璮unction涔熸槸鍙互浣滀負鍙橀噺鐨勶紝鎵浠ユ垜浠彲浠ュ湪鑷繁灝佽鐨勬鏋朵腑棰勭暀鍥炶皟鍑芥暟渚涜嚜瀹氫箟浣跨敤錛屽涓嬮潰鐨勪唬鐮侊細
 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銆丣S涓彲浠ヤ嬌鐢ㄦ鍒欒〃杈懼紡鏉ユ牎楠屾暟瀛楀煙銆佹棩鏈熷煙鍜孍Mail絳夈備唬鐮佺ず渚嬪涓嬶細
鏍¢獙鏃ユ湡鐨勪緥瀛愶細
 1     function isDate(date){
 2         //瀵規棩鏈熸牸寮忚繘琛岄獙璇?nbsp;瑕佹眰涓?000-2099騫?nbsp; 鏍煎紡涓?nbsp;yyyy-mm-dd 騫朵笖鍙互姝e父杞崲鎴愭紜殑鏃ユ湡
 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     }
  榪欑瘒鏂囩珷鏈夎緇嗙殑璇存槑錛?a target="_blank" href="http://www.tkk7.com/byterat/archive/2006/12/20/89143.html">http://www.tkk7.com/byterat/archive/2006/12/20/89143.html
  榪欐湰鐢靛瓙涔︽槸璁茶В姝e垯琛ㄨ揪寮忕殑錛?a target="_blank" href="http://www.tkk7.com/Files/kawaii/RegularExpressions.zip">http://www.tkk7.com/Files/kawaii/RegularExpressions.zip 
6銆佸湪JS緙栫爜涓紝濡傛灉浠g爜閲忚緝澶э紝瑕佹敞鎰忛槻姝unction鍚嶇О閲嶅錛屽寘鎷洿鎺ュ湪欏甸潰涓婄紪鍐欑殑鍜屽紩鐢ㄥ閮↗S鏂囦歡鐨勶紝涓嶇劧浼氬嚭鐜頒竴浜涜帿鍚嶅濡欑殑闂錛?br /> 7銆佹敞鎰廕S浠g爜涓殑鍑芥暟榪斿洖璇彞return鐨勪嬌鐢紱
8銆佸敖閲忔妸JS浠g爜鍐欏湪澶栭儴鍏叡鐨勬枃浠朵腑錛岃屽湪欏甸潰涓紩鍏ワ紝濂藉鏈夛細a.鍑芥暟澶嶇敤錛沚.JS鏂囦歡緙撳瓨錛沜.鎻愪緵欏甸潰瑙f瀽閫熷害銆傚熀浜巄錛屾垜浠湪淇敼JS浠g爜鍚庯紝瑕佺湅IE鐨勮緗槸鍚﹀皢鍘熷厛鐨凧S鏂囦歡緙撳瓨閫犳垚闂錛?br /> 9銆佸浜庡悓涓涓〉闈㈢殑澶氫釜琛ㄥ崟鎻愪氦錛屾垜浠彲浠ュ湪絎竴涓〃鍗曚腑璁劇疆鐩稿簲鐨勯殣钘忓煙錛屽湪琛ㄥ崟鎻愪氦涔嬪墠鍒╃敤JS鑴氭湰鎶婂叾浠栬〃鍗曠殑鏁版嵁璁劇疆鍒扮涓涓〃鍗曠殑闅愯棌鍩熶腑錛?br /> 10銆佸浜庡紓姝ユ牎楠岀殑鏂囨湰妗嗭紝鎴戜滑涓鑸緗Е鍙戜簨浠朵負onblur鑰屼笉鏄痮nchange鎴栬卭npropertychange錛屼互鍑忓皯瀹㈡埛绔拰鏈嶅姟鍣ㄧ殑浜や簰嬈℃暟錛屼絾搴旇娉ㄦ剰濡傛灉榪欎釜鏂囨湰妗嗘渶鍒濇病鏈夎幏寰楃劍鐐癸紝閭d箞onblur灝變笉浼氳Е鍙戯紝鍙互鍏堣皟鐢ㄤ互涓媜nfocus錛屽啀璋冪敤onblur鎵嬪姩瑙﹀彂錛?br /> 11銆丣S涓笉瀛樺湪trim()鍑芥暟錛岃嚜瀹氫箟濡備笅錛?br />
 1 //JS鍘婚櫎棣栧熬絀烘牸錛堝悓VBS鐨凾rim)
 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                //媯鏌ュ瓧絎︿覆寮濮嬮儴鍒嗙殑絀烘牸
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             //媯鏌ュ瓧絎︿覆緇撴潫閮ㄥ垎鐨勭┖鏍?/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             //灝嗘枃瀛椾腑闂村涓浉榪炵殑絀烘牸鍙樹負涓涓┖鏍?/span>
21             retValue = retValue.substring(0, retValue.indexOf("  ")) 
22                 + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
23         }
24         return retValue;
25     }
12銆丣S涓樉紺烘ā寮忕獥鍙o紝浠g爜濡備笅錛?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 
鍦ㄦ柊鎵撳紑鐨勬ā寮忕獥鍙d腑錛屾垜浠氳繃window.returnValue璁劇疆榪斿洖鍊鹼紝鐒跺悗鍦ㄧ埗欏甸潰涓垜浠氳繃returnVal鍙互鎷垮埌榪斿洖鍊箋?br />

lixw 2007-11-27 23:41 鍙戣〃璇勮
]]>
DB2甯哥敤鍛戒護http://www.tkk7.com/kawaii/archive/2007/04/27/113978.htmllixwlixwFri, 27 Apr 2007 00:54:00 GMThttp://www.tkk7.com/kawaii/archive/2007/04/27/113978.htmlhttp://www.tkk7.com/kawaii/comments/113978.htmlhttp://www.tkk7.com/kawaii/archive/2007/04/27/113978.html#Feedback0http://www.tkk7.com/kawaii/comments/commentRss/113978.htmlhttp://www.tkk7.com/kawaii/services/trackbacks/113978.html  db2start   
  2錛?鍋滄鏁版嵁搴?nbsp;  
  db2stop   
  3錛?榪炴帴鏁版嵁搴?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  4錛?璇繪暟鎹簱綆$悊紼嬪簭閰嶇疆   
  db2   get   dbm   cfg   
  5錛?鍐欐暟鎹簱綆$悊紼嬪簭閰嶇疆   
  db2   update   dbm   cfg   using   鍙傛暟鍚?nbsp;  鍙傛暟鍊?nbsp;  
  6錛?璇繪暟鎹簱鐨勯厤緗?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   get   db   cfg   for   o_yd   
  7錛?鍐欐暟鎹簱鐨勯厤緗?nbsp;  
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   update   db   cfg   for   o_yd   using   鍙傛暟鍚?nbsp;  鍙傛暟鍊?nbsp;  
  8錛?鍏抽棴鎵鏈夊簲鐢ㄨ繛鎺?nbsp;  
  db2   force   application   all   
  db2   force   application   ID1,ID2,,,Idn   MODE   ASYNC   
  (db2   list   application   for   db   o_yd   show   detail)   
  9錛?澶囦喚鏁版嵁搴?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錛?鎭㈠鏁版嵁搴?nbsp;  
  db2   restore   db   o_yd   from   d:   to   d:     
  db2   restore   db   o_yd   from   \\.\tape0   to   d:   
  11錛?緇戝畾瀛樺偍榪囩▼   
  db2   connect   to   o_yd   user   db2   using   pwd   
  db2   bind   c:\dfplus.bnd   
  鎷瘋礉瀛樺偍榪囩▼鍒版湇鍔″櫒涓婄殑C:\sqllib\function鐩綍涓?nbsp;  
  12錛?鏁寸悊琛?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錛?瀵煎嚭琛ㄦ暟鎹?nbsp; 
  db2   export   to   c:\sw.txt   of   del   select   *   from   dftz  
  db2   export   to   c:\sw.ixf   of   ixf   select   *   from   dftz  
  14錛?瀵煎叆琛ㄦ暟鎹?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       (浠匢XF)  
  db2   import   to   c:\dftz.ixf   of   ixf   commitcount   5000   replace_create   into   dftz     (浠匢XF)  
  15錛?鎵ц涓涓壒澶勭悊鏂囦歡  
  db2   –tf   鎵瑰鐞嗘枃浠跺悕  
  錛堟枃浠朵腑姣忎竴鏉″懡浠ょ敤   錛涚粨鏉燂級  
  16錛?鑷姩鐢熸垚鎵瑰鐞嗘枃浠?nbsp; 
  寤烘枃鏈枃浠訛細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錛?鑷姩鐢熸垚寤鴻〃錛堣鍥撅級璇彞  
  鍦ㄦ湇鍔″櫒涓婏細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錛?鍏朵粬鍛戒護  
  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   



lixw 2007-04-27 08:54 鍙戣〃璇勮
]]>
log4j綆浠?/title><link>http://www.tkk7.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.tkk7.com/kawaii/archive/2007/04/25/113581.html</guid><wfw:comment>http://www.tkk7.com/kawaii/comments/113581.html</wfw:comment><comments>http://www.tkk7.com/kawaii/archive/2007/04/25/113581.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/kawaii/comments/commentRss/113581.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/kawaii/services/trackbacks/113581.html</trackback:ping><description><![CDATA[1.鍦ㄥ簲鐢ㄧ▼搴忎腑浣跨敤鏃ュ織鐨勪笁涓洰鐨勶細<br>搴旂敤紼嬪簭涓坊鍔犳棩蹇楃殑涓変釜鐩殑錛氱洃瑙嗕唬鐮佷腑鍙橀噺鐨勫彉鍖栨儏鍐碉紝鍛ㄦ湡鎬х殑璁板綍鍒版枃浠朵腑渚涘叾浠栧簲鐢ㄨ繘琛岀粺璁″垎鏋愬伐浣滐紱<br>璺熻釜浠g爜榪愯鏃惰建榪癸紝浣滀負鏃ュ悗瀹¤鐨勪緷鎹紱<br>鎷呭綋闆嗘垚寮鍙戠幆澧冧腑鐨勮皟璇曞櫒鐨勪綔鐢紝鍚戞枃浠舵垨鎺у埗鍙版墦鍗頒唬鐮佺殑璋冭瘯淇℃伅銆?br><br>2.log4j鐢變笁涓噸瑕佺殑緇勪歡鏋勬垚錛氭棩蹇椾俊鎭殑浼樺厛綰э紝鏃ュ織淇℃伅鐨勮緭鍑虹洰鐨勫湴錛屾棩蹇椾俊鎭殑杈撳嚭鏍煎紡銆?br>浣跨敤Java鐗規ф枃浠跺仛涓洪厤緗枃浠剁殑鏂規硶錛?br>2.1. 閰嶇疆鏍筁ogger錛屽叾璇硶涓猴細<br>log4j.rootLogger = [ level ] , appenderName, appenderName, ...<br>鍏朵腑錛宭evel 鏄棩蹇楄褰曠殑浼樺厛綰э紝鍒嗕負OFF銆丗ATAL銆丒RROR銆乄ARN銆両NFO銆丏EBUG銆丄LL鎴栬呮偍瀹氫箟鐨勭駭鍒?br>Log4j寤鴻鍙嬌鐢ㄥ洓涓駭鍒紝浼樺厛綰т粠楂樺埌浣庡垎鍒槸ERROR銆乄ARN銆両NFO銆丏EBUG銆?br>閫氳繃鍦ㄨ繖閲屽畾涔夌殑綰у埆錛屾偍鍙互鎺у埗鍒板簲鐢ㄧ▼搴忎腑鐩稿簲綰у埆鐨勬棩蹇椾俊鎭殑寮鍏熾?br>姣斿鍦ㄨ繖閲屽畾涔変簡INFO綰у埆錛屽垯搴旂敤紼嬪簭涓墍鏈塂EBUG綰у埆鐨勬棩蹇椾俊鎭皢涓嶈鎵撳嵃鍑烘潵銆?br>appenderName灝辨槸鎸囧畾鏃ュ織淇℃伅杈撳嚭鍒板摢涓湴鏂廣傛偍鍙互鍚屾椂鎸囧畾澶氫釜杈撳嚭鐩殑鍦般?br>2.2. 閰嶇疆鏃ュ織淇℃伅杈撳嚭鐩殑鍦癆ppender錛屽叾璇硶涓?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>鍏朵腑錛孡og4j鎻愪緵鐨刟ppender鏈変互涓嬪嚑縐嶏細<br>org.apache.log4j.ConsoleAppender錛堟帶鍒跺彴錛夛紝<br>org.apache.log4j.FileAppender錛堟枃浠訛級錛?br>org.apache.log4j.DailyRollingFileAppender錛堟瘡澶╀駭鐢熶竴涓棩蹇楁枃浠訛級錛?br>org.apache.log4j.RollingFileAppender錛堟枃浠跺ぇ灝忓埌杈炬寚瀹氬昂瀵哥殑鏃跺欎駭鐢熶竴涓柊鐨勬枃浠訛級錛?br>org.apache.log4j.WriterAppender錛堝皢鏃ュ織淇℃伅浠ユ祦鏍煎紡鍙戦佸埌浠繪剰鎸囧畾鐨勫湴鏂癸級<br><br>2.3. 閰嶇疆鏃ュ織淇℃伅鐨勬牸寮忥紙甯冨眬錛夛紝鍏惰娉曚負錛?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>鍏朵腑錛孡og4j鎻愪緵鐨刲ayout鏈変互涓嬪嚑縐嶏細<br>org.apache.log4j.HTMLLayout錛堜互HTML琛ㄦ牸褰㈠紡甯冨眬錛夛紝<br>org.apache.log4j.PatternLayout錛堝彲浠ョ伒媧誨湴鎸囧畾甯冨眬妯″紡錛夛紝<br>org.apache.log4j.SimpleLayout錛堝寘鍚棩蹇椾俊鎭殑綰у埆鍜屼俊鎭瓧絎︿覆錛夛紝<br>org.apache.log4j.TTCCLayout錛堝寘鍚棩蹇椾駭鐢熺殑鏃墮棿銆佺嚎紼嬨佺被鍒瓑絳変俊鎭級<br><br>3.鍦ㄤ唬鐮佷腑浣跨敤Log4j,涓嬮潰灝嗚榪板湪紼嬪簭浠g爜涓庢牱浣跨敤Log4j銆?br><br>3.1.寰楀埌璁板綍鍣?br>浣跨敤Log4j錛岀涓姝ュ氨鏄幏鍙栨棩蹇楄褰曞櫒錛岃繖涓褰曞櫒灝嗚礋璐f帶鍒舵棩蹇椾俊鎭傚叾璇硶涓猴細<br>public static Logger getLogger( String name)錛?br>閫氳繃鎸囧畾鐨勫悕瀛楄幏寰楄褰曞櫒錛屽鏋滃繀瑕佺殑璇濓紝鍒欎負榪欎釜鍚嶅瓧鍒涘緩涓涓柊鐨勮褰曞櫒銆侼ame涓鑸彇鏈被鐨勫悕瀛楋紝姣斿錛?br>static Logger logger = Logger.getLogger ( ServerWithLog4j.class.getName () ) ;<br><br>3.2.璇誨彇閰嶇疆鏂囦歡<br>褰撹幏寰椾簡鏃ュ織璁板綍鍣ㄤ箣鍚庯紝絎簩姝ュ皢閰嶇疆Log4j鐜錛屽叾璇硶涓猴細<br>BasicConfigurator.configure ()錛?鑷姩蹇熷湴浣跨敤緙虹渷Log4j鐜銆?br>PropertyConfigurator.configure ( String configFilename) 錛氳鍙栦嬌鐢↗ava鐨勭壒鎬ф枃浠剁紪鍐欑殑閰嶇疆鏂囦歡銆?br>DOMConfigurator.configure ( String filename ) 錛氳鍙朮ML褰㈠紡鐨勯厤緗枃浠躲?br><br>3.3.鎻掑叆璁板綍淇℃伅錛堟牸寮忓寲鏃ュ織淇℃伅錛?br>褰撲笂涓や釜蹇呰姝ラ鎵ц瀹屾瘯錛屾偍灝卞彲浠ヨ交鏉懼湴浣跨敤涓嶅悓浼樺厛綰у埆鐨勬棩蹇楄褰曡鍙ユ彃鍏ュ埌鎮ㄦ兂璁板綍鏃ュ織鐨勪換浣曞湴鏂癸紝鍏惰娉曞涓嬶細<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.tkk7.com/kawaii/aggbug/113581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/kawaii/" target="_blank">lixw</a> 2007-04-25 17:34 <a href="http://www.tkk7.com/kawaii/archive/2007/04/25/113581.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>澶氱嚎紼嬬洃鍚枃浠舵敼鍔?/title><link>http://www.tkk7.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.tkk7.com/kawaii/archive/2007/02/08/98668.html</guid><wfw:comment>http://www.tkk7.com/kawaii/comments/98668.html</wfw:comment><comments>http://www.tkk7.com/kawaii/archive/2007/02/08/98668.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.tkk7.com/kawaii/comments/commentRss/98668.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/kawaii/services/trackbacks/98668.html</trackback:ping><description><![CDATA[涓縐嶆瘮杈冪畝闄嬬殑鏂規硶錛?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);">鍚姩鐩戝惉綰跨▼</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鐨勮В鍐蟲柟娉曪細<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.tkk7.com/kawaii/aggbug/98668.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/kawaii/" target="_blank">lixw</a> 2007-02-08 10:07 <a href="http://www.tkk7.com/kawaii/archive/2007/02/08/98668.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏍規嵁涓嶅悓Locale鍊艱鍙栦笉鍚岀殑Properties閰嶇疆鏂囦歡http://www.tkk7.com/kawaii/archive/2007/02/08/98652.htmllixwlixwThu, 08 Feb 2007 01:43:00 GMThttp://www.tkk7.com/kawaii/archive/2007/02/08/98652.htmlhttp://www.tkk7.com/kawaii/comments/98652.htmlhttp://www.tkk7.com/kawaii/archive/2007/02/08/98652.html#Feedback0http://www.tkk7.com/kawaii/comments/commentRss/98652.htmlhttp://www.tkk7.com/kawaii/services/trackbacks/98652.html
1//file聽may聽be聽named聽basename_locale.properties
2ResourceBundle聽bundle聽=聽ResourceBundle.getBundle("basename");
3//聽Enumerate聽contents聽of聽resource聽bundle
4//The聽next聽two聽lines聽should聽be聽in聽one聽line.
5for聽(Enumeration聽props聽=聽bundle.getKeys();props.hasMoreElements();聽)聽{
6聽聽聽聽String聽key聽=聽(String)props.nextElement();
7聽聽聽聽process(key,聽bundle.getObject(key));
8}



lixw 2007-02-08 09:43 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 中文字幕免费不卡二区| 免费无码肉片在线观看| 亚洲精品V欧洲精品V日韩精品| 国产精品亚洲不卡一区二区三区| 亚洲无圣光一区二区| 成人au免费视频影院| 国产男女爽爽爽免费视频| 久久亚洲高清观看| 天天看片天天爽_免费播放| 全黄A免费一级毛片| 亚洲精品国产手机| 亚洲毛片av日韩av无码| 中文字幕无码播放免费| 一级做a爰片久久免费| 亚洲午夜久久久久久尤物| 国产亚洲情侣一区二区无| 在线观看AV片永久免费| 中文字幕乱码系列免费| 一本天堂ⅴ无码亚洲道久久| 国产aⅴ无码专区亚洲av| 免费又黄又硬又爽大片| 免费AA片少妇人AA片直播| 狠狠躁狠狠爱免费视频无码| 中中文字幕亚洲无线码| 亚洲国产精品VA在线看黑人| 免费无码看av的网站| 91精品国产免费| 久久精品无码免费不卡| 亚洲a∨国产av综合av下载| 亚洲最大的成网4438| 亚洲午夜福利AV一区二区无码| 免费萌白酱国产一区二区三区 | 日韩在线视频免费| 亚洲成av人片不卡无码| 国产精品亚洲а∨无码播放| 国产在线19禁免费观看| 欧美三级在线电影免费| 91精品啪在线观看国产线免费| 激情综合亚洲色婷婷五月| 久久亚洲美女精品国产精品| 亚洲一级Av无码毛片久久精品|