??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲不卡视频在线观看,老汉色老汉首页a亚洲,亚洲精品tv久久久久久久久久http://www.tkk7.com/fingki/category/36830.htmlzh-cnThu, 04 Mar 2010 16:03:43 GMTThu, 04 Mar 2010 16:03:43 GMT60使用Iterator 或for-each注意Qjava.util.ConcurrentModificationExceptionhttp://www.tkk7.com/fingki/archive/2010/03/02/314268.htmlFingki.liFingki.liTue, 02 Mar 2010 04:22:00 GMThttp://www.tkk7.com/fingki/archive/2010/03/02/314268.htmlhttp://www.tkk7.com/fingki/comments/314268.htmlhttp://www.tkk7.com/fingki/archive/2010/03/02/314268.html#Feedback1http://www.tkk7.com/fingki/comments/commentRss/314268.htmlhttp://www.tkk7.com/fingki/services/trackbacks/314268.html 1.如果你仅仅是对collectionq行遍历查询Q那么不必担心什么?br /> 2.但如果你在遍历过E中要对collectionq行删除Q那么你p注意了?br /> For example:
private void testDel() {  
  1.     List<String> list = new ArrayList<String>();  
  2.     for (int i = 0; i < 10; i++) {  
  3.         String str = "td" + i;  
  4.         list.add(str);  
  5.     }  
  6.   
  7.     for (Iterator it = list.iterator(); it.hasNext();) {  
  8.         String str = (String) it.next();  
  9.         if (str.equals("td5")) {  
  10.             // list.remove(str);  // 删除Ҏ一 
  11.             it.remove();  // 删除Ҏ?nbsp;
  12.         }  
  13.     }  

上面的代码运行没有问题,但如果你?#8220;Ҏ一”替代“Ҏ?#8221;Q则会出现java.util.ConcurrentModificationException?br /> Q用for-each遍历也会ZcM问题Q?br /> 具体原因是可以看一?span style="color: #000000;">先看看List中的removeҎ源码Q?br />
  1. public boolean remove(Object o) {  
  2.     if (o == null) {  
  3.         for (int index = 0; index < size; index++)  
  4.             if (elementData[index] == null) {  
  5.                 fastRemove(index);  
  6.                 return true;  
  7.             }  
  8.     } else {  
  9.         for (int index = 0; index < size; index++)  
  10.             if (o.equals(elementData[index])) {  
  11.                 fastRemove(index);  
  12.                 return true;  
  13.             }  
  14.     }  
  15.     return false;  
  16. }  
  17.   
  18. private void fastRemove(int index) {  
  19.     modCount++; // 特别注意q里Q这里只增加了modCount的?nbsp; 
  20.     int numMoved = size - index - 1;  
  21.     if (numMoved > 0)  
  22.         System.arraycopy(elementData, index + 1, elementData, index,  
  23.                 numMoved);  
  24.     elementData[--size] = null; // Let gc do its work  

接着看。删除后得到下一个元素的代码Qit.next():  it为AbstractList的内部类Iterator的一个实例?br />
  1. public E next() {  
  2.     checkForComodification();  
  3.     try {  
  4.         E next = get(cursor);  
  5.         lastRet = cursor++;  
  6.         return next;  
  7.     } catch (IndexOutOfBoundsException e) {  
  8.         checkForComodification();  
  9.         throw new NoSuchElementException();  
  10.     }  
  11. }  
  12.   
  13. final void checkForComodification() {  //注意q个Ҏ
  14.     if (modCount != expectedModCount)  //查这两个值是否相?/li>
  15.         throw new ConcurrentModificationException();  

最后看Iterator的remove()Ҏ的源代码Q?br />
  1. public void remove() {  
  2.     if (lastRet == -1)  
  3.         throw new IllegalStateException();  
  4.     checkForComodification();  
  5.     try {  
  6.         AbstractList.this.remove(lastRet);  
  7.         if (lastRet < cursor)  
  8.             cursor--;  
  9.         lastRet = -1;  
  10.         expectedModCount = modCount; // 讄expectedModCount  
  11.     } catch (IndexOutOfBoundsException e) {  
  12.         throw new ConcurrentModificationException();  
  13.     }  
  14. }  
  15.   
  16. final void checkForComodification() {  
  17.     if (modCount != expectedModCount)  
  18.         throw new ConcurrentModificationException();  

q下明白了Qlist的removeҎ只修改了modCount|而iterator的remove能同步modCount和expectedModCount.





Fingki.li 2010-03-02 12:22 发表评论
]]>
各国语言代码?/title><link>http://www.tkk7.com/fingki/archive/2009/12/23/307062.html</link><dc:creator>Fingki.li</dc:creator><author>Fingki.li</author><pubDate>Wed, 23 Dec 2009 09:33:00 GMT</pubDate><guid>http://www.tkk7.com/fingki/archive/2009/12/23/307062.html</guid><wfw:comment>http://www.tkk7.com/fingki/comments/307062.html</wfw:comment><comments>http://www.tkk7.com/fingki/archive/2009/12/23/307062.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fingki/comments/commentRss/307062.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fingki/services/trackbacks/307062.html</trackback:ping><description><![CDATA[<p>各国语言代码列表Q?br /> English 1033 1033 <br /> German 1031 1031 <br /> French 1036 1036 <br /> Japanese 1041 1041 <br /> Danish 1030 1030 <br /> Spanish 3082 3082 <br /> Italian 1040 1040 <br /> Dutch 1043 1043 <br /> Norwegian 2068 2068 <br /> Portuguese 2070 2070 <br /> Finnish 1035 1035 <br /> Swedish 1053 1053 <br /> Czech 1029 1029 <br /> Hungarian 1038 1038 <br /> Polish 1045 1045 <br /> Romanian 1048 1048 <br /> Croatian 1050 1050 <br /> Slovak 1051 1051 <br /> Slovene 1060 1060 <br /> Greek 1032 1032 <br /> Bulgarian 1026 1026 <br /> Russian 1049 1049 <br /> Turkish 1055 1055 <br /> British English 2057 1033 <br /> Estonian 1061 1061 <br /> Latvian 1062 1062 <br /> Lithuanian 1063 1063 <br /> Brazilian 1046 1046 <br /> Traditional Chinese 1028 1028 <br /> Korean 1042 1042 <br /> Simplified Chinese 2052 2052 <br /> Arabic 1025 1025 <br /> Thai 1054 1054</p> <img src ="http://www.tkk7.com/fingki/aggbug/307062.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fingki/" target="_blank">Fingki.li</a> 2009-12-23 17:33 <a href="http://www.tkk7.com/fingki/archive/2009/12/23/307062.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>要理解IOCQ推荐: 看《墨攅R理解IoC概念http://www.tkk7.com/fingki/archive/2009/08/13/290949.htmlFingki.liFingki.liThu, 13 Aug 2009 02:34:00 GMThttp://www.tkk7.com/fingki/archive/2009/08/13/290949.htmlhttp://www.tkk7.com/fingki/comments/290949.htmlhttp://www.tkk7.com/fingki/archive/2009/08/13/290949.html#Feedback1http://www.tkk7.com/fingki/comments/commentRss/290949.htmlhttp://www.tkk7.com/fingki/services/trackbacks/290949.htmlIOC从字面来看不Ҏ懂,但如果你看了q篇文章Q相信你一定会懂?
佩服原作者!  阅读全文

Fingki.li 2009-08-13 10:34 发表评论
]]>
Linux下application中文昄为方?/title><link>http://www.tkk7.com/fingki/archive/2009/07/06/285640.html</link><dc:creator>Fingki.li</dc:creator><author>Fingki.li</author><pubDate>Mon, 06 Jul 2009 02:27:00 GMT</pubDate><guid>http://www.tkk7.com/fingki/archive/2009/07/06/285640.html</guid><wfw:comment>http://www.tkk7.com/fingki/comments/285640.html</wfw:comment><comments>http://www.tkk7.com/fingki/archive/2009/07/06/285640.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fingki/comments/commentRss/285640.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fingki/services/trackbacks/285640.html</trackback:ping><description><![CDATA[     摘要: Linux下application中文昄为方块问题的解决  <a href='http://www.tkk7.com/fingki/archive/2009/07/06/285640.html'>阅读全文</a><img src ="http://www.tkk7.com/fingki/aggbug/285640.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fingki/" target="_blank">Fingki.li</a> 2009-07-06 10:27 <a href="http://www.tkk7.com/fingki/archive/2009/07/06/285640.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>css hover ?jqueryhttp://www.tkk7.com/fingki/archive/2009/05/21/271887.htmlFingki.liFingki.liThu, 21 May 2009 02:51:00 GMThttp://www.tkk7.com/fingki/archive/2009/05/21/271887.htmlhttp://www.tkk7.com/fingki/comments/271887.htmlhttp://www.tkk7.com/fingki/archive/2009/05/21/271887.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/271887.htmlhttp://www.tkk7.com/fingki/services/trackbacks/271887.html阅读全文

Fingki.li 2009-05-21 10:51 发表评论
]]>
DWR对象参数问题http://www.tkk7.com/fingki/archive/2009/04/23/267158.htmlFingki.liFingki.liThu, 23 Apr 2009 07:23:00 GMThttp://www.tkk7.com/fingki/archive/2009/04/23/267158.htmlhttp://www.tkk7.com/fingki/comments/267158.htmlhttp://www.tkk7.com/fingki/archive/2009/04/23/267158.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/267158.htmlhttp://www.tkk7.com/fingki/services/trackbacks/267158.html Ҏ使用对象参数时报错如下:
Erroring: batchId[0] message[org.directwebremoting.extend.MarshallException: Error marshalling test.User:

一个最可能的原因是 User没有一个无参的construction?br />
晕。。?br /> 朋友们注意呀Q?br />

Fingki.li 2009-04-23 15:23 发表评论
]]>
以太|环境下UDP传输中的数据包长度问?/title><link>http://www.tkk7.com/fingki/archive/2009/04/10/264877.html</link><dc:creator>Fingki.li</dc:creator><author>Fingki.li</author><pubDate>Fri, 10 Apr 2009 08:35:00 GMT</pubDate><guid>http://www.tkk7.com/fingki/archive/2009/04/10/264877.html</guid><wfw:comment>http://www.tkk7.com/fingki/comments/264877.html</wfw:comment><comments>http://www.tkk7.com/fingki/archive/2009/04/10/264877.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fingki/comments/commentRss/264877.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fingki/services/trackbacks/264877.html</trackback:ping><description><![CDATA[对于以太|环境下UDP传输中的数据包长度问?br /> <br /> 首先要看TCP/IP协议Q涉及到四层Q链路层Q网l层Q传输层Q应用层?br /> 其中以太|(EthernetQ的数据帧在链\?br /> IP包在|络?br /> TCP或UDP包在传输?br /> TCP或UDP中的数据QData)在应用层<br /> 它们的关pL 数据帧{IP包{TCP或UDP包{Data}}?br /> 在应用程序中我们用到的Data的长度最大是多少Q直接取决于底层的限制?br /> 我们从下C分析一下:<br /> 在链路层Q由以太|的物理Ҏ决定了数据帧的长度为(46Q?8Q-Q?500Q?8Q,其中?8是数据的头和尾Q也是说数据的内Ҏ大ؓ1500Q即MTUQMaximum Transmission UnitQؓ1500Q?br /> 在网l层Q因为IP包的首部要占?0字节Q所以这的MTU?500Q?0Q?480Q?br /> 在传输层Q对于UDP包的首部要占?字节Q所以这的MTU?480Q?Q?472Q?br /> 所以,在应用层Q你的Data最大长度ؓ1472?br /> Q当我们的UDP包中的数据多于MTU(1472)Ӟ发送方的IP层需要分片fragmentationq行传输Q而在接收方IP层则需要进行数据报重组Q由于UDP是不可靠的传输协议,如果分片丢失D重组p|Q将DUDP数据包被丢弃Q?br /> 从上面的分析来看Q在普通的局域网环境下,UDP的数据最大ؓ1472字节最好(避免分片重组Q?br /> 但在|络~程中,Internet中的路由器可能有讄成不同的|于默认|QInternet上的标准MTUgؓ576Q所以Internet的UDP~程时数据长度最好在576Q?0Q?Q?48字节以内?br /> MTUҎ们的UDP~程很重要,那如何查看\qMTU值呢Q?br /> 对于windows OS: ping -f -l <data_length> <gateway_IP><br /> 如:ping -f -l 1472 192.168.0.1<br /> 如果提示QPackets needs to be fragmented but DF set.<br /> 则表明MTU于1500Q不断改data_length|可以最l测出gateway的MTU|<br /> 对于linux OS: ping -c <number> -M do -s <data_length> <gateway_IP><br /> 如: ping -c 1 -M do -s 1472 192.168.0.1<br /> 如果提示 Frag needed and DF set……<br /> 则表明MTU于1500Q可以再以推算gateway的MTU?br /> 当然要修改MTU的|那就是网的事了Q一般h没这权限呀Q,我们只能甌加等待了 ^-^ .<br /> <br /> <img src ="http://www.tkk7.com/fingki/aggbug/264877.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fingki/" target="_blank">Fingki.li</a> 2009-04-10 16:35 <a href="http://www.tkk7.com/fingki/archive/2009/04/10/264877.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSCalendar 使用样例http://www.tkk7.com/fingki/archive/2009/02/17/255112.htmlFingki.liFingki.liTue, 17 Feb 2009 07:35:00 GMThttp://www.tkk7.com/fingki/archive/2009/02/17/255112.htmlhttp://www.tkk7.com/fingki/comments/255112.htmlhttp://www.tkk7.com/fingki/archive/2009/02/17/255112.html#Feedback8http://www.tkk7.com/fingki/comments/commentRss/255112.htmlhttp://www.tkk7.com/fingki/services/trackbacks/255112.htmlJSCalendar 日历控g 使用样例如下Q?br /> <html>
<head>
    <style type="text/css">@import url( /js/jscalendar/calendar-win2k-cold-1.css );</style>
    <script type="text/javascript" src="/js/jscalendar/calendar.js"></script>
    <script type="text/javascript" src="/js/jscalendar/i18n.jsp"></script>//不用i18n可以指定语言 如:<script type="text/javascript" src="/js/jscalendar/lang/calendar-en.js"></script>
    <script type="text/javascript" src="/js/jscalendar/calendar-setup.js"></script>
</head>
<body>
<input type="text" size="10" name="fromDate" id="fromDate" maxlength="10" onchange="checkSpecific();" value=""/>
<img src="images/icon_calendarpicker.gif" id="fromDateCal" />
<br>
<script type="text/javascript" >
    Calendar.setup(
    {
        inputField  : "fromDate",       // ID of the input field
        ifFormat    : "%m/%d/%Y",       // the date format
        button      : "fromDateCal",    // ID of the button
    });
</script>
</body>
</html>
上述CZ代码在jsp容器中运行完全正常?br />

Fingki.li 2009-02-17 15:35 发表评论
]]>
有关序列化的问题 java.io.InvalidClassExceptionhttp://www.tkk7.com/fingki/archive/2009/01/13/251100.htmlFingki.liFingki.liTue, 13 Jan 2009 03:46:00 GMThttp://www.tkk7.com/fingki/archive/2009/01/13/251100.htmlhttp://www.tkk7.com/fingki/comments/251100.htmlhttp://www.tkk7.com/fingki/archive/2009/01/13/251100.html#Feedback1http://www.tkk7.com/fingki/comments/commentRss/251100.htmlhttp://www.tkk7.com/fingki/services/trackbacks/251100.html java.io.InvalidClassException: com.test.Test; local class incompatible: stream classdesc serialVersionUID = 7981560250804078637, local class serialVersionUID = -8334405535174160822
q是序列化兼Ҏ所_
java通过一个名为UIDQstream unique identifierQ来控制Q这个UID是隐式的Q它通过cdQ方法名{诸多因素经q计而得Q理Z是一一映射的关p,也就是唯一的。如果UID不一 L话,无法实现反序列化了Qƈ且将会得到InvalidClassException?br /> 当要Zؓ的生一个新的版本(实现q没有改动)Q而抛弃以前的版本的话Q可以通过昑ּ的声名UID来实玎ͼ
private static final long serialVersionUID=????;//(你可以编造一个UIDQ但不能有重?

对于上例我们可以在com.test.TestcM加入 Q?br /> private static final long serialVersionUID=7981560250804078637l;
q样p决了新老版本的兼容性问题?br /> 当然Q对于序列化q有很多问题Q慢慢研I吧?br />


Fingki.li 2009-01-13 11:46 发表评论
]]>
有关 volatie 关键?/title><link>http://www.tkk7.com/fingki/archive/2009/01/06/250106.html</link><dc:creator>Fingki.li</dc:creator><author>Fingki.li</author><pubDate>Tue, 06 Jan 2009 07:24:00 GMT</pubDate><guid>http://www.tkk7.com/fingki/archive/2009/01/06/250106.html</guid><wfw:comment>http://www.tkk7.com/fingki/comments/250106.html</wfw:comment><comments>http://www.tkk7.com/fingki/archive/2009/01/06/250106.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fingki/comments/commentRss/250106.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fingki/services/trackbacks/250106.html</trackback:ping><description><![CDATA[<p>对volatileQ看C个很清楚的解释,摘录下来如下Q?br /> </p> <p>volatile关键字有什么用Q?br /> 恐怕比较一下volatile和synchronized的不同是最Ҏ解释清楚的。volatile是变量修饰符Q而synchronized则作用于一D代码或ҎQ看如下三句get代码Q?/p> <div> <ol ln-show="" title="Double click to hide line number." ondblclick="linenumber(this)"> <li>int<span style="color: Blue;">i1</span><span style="color: Gray;">;              </span>int<span style="color: Blue;">geti1</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i1</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> <li><span style="color: Green;">volatile</span> int<span style="color: Blue;">i2</span><span style="color: Gray;">;              </span>int<span style="color: Blue;">geti2</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i2</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> <li><span style="color: Gray;">         </span>int <span style="color: Blue;">i3</span><span style="color: Gray;">; </span><span style="color: Green;">synchronized</span>int<span style="color: Blue;">geti3</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i3</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> </ol> </div> <p>  geti1()得到存储在当前线E中i1的数倹{多个线E有多个i1变量拯Q而且q些i1之间可以互不相同。换句话_另一个线E可能已l改 变了它线E内的i1|而这个值可以和当前U程中的i1g相同。事实上QJava有个思想?#8220;?#8221;内存区域Q这里存放了变量目前?#8220;准确?#8221;。每个线E? 可以有它自己的变量拷贝,而这个变量拷贝值可以和“?#8221;内存区域里存攄不同。因此实际上存在一U可能:“?#8221;内存区域里的i1值是1Q线E?里的i1? ?Q线E?里的i1值是3——这在线E?和线E?都改变了它们各自的i1|而且q个改变q没来得及传递给“?#8221;内存区域或其他线E时׃发生?br /> 而geti2()得到的是“?#8221;内存区域的i2数倹{用volatile修饰后的变量不允许有不同?#8220;?#8221;内存区域的变量拷贝。换句话_一个变量经 volatile修饰后在所有线E中必须是同步的QQ何线E中改变了它的|所有其他线E立卌取到了相同的倹{理所当然的,volatile修饰的变? 存取时比一般变量消耗的资源要多一点,因ؓU程有它自己的变量拷贝更为高效?br /> 既然volatile关键字已l实CU程间数据同步,又要synchronizedq什么呢Q呵呵,它们之间有两点不同。首 先,synchronized获得q攄视器——如果两个线E用了同一个对象锁Q监视器能强制保证代码块同时只被一个线E所执行——这是众所周知的事 实。但是,synchronized也同步内存:事实上,synchronized?#8220;?#8221;内存区域同步整个U程的内存。因此,执行geti3()Ҏ? 了如下几步:<br /> 1. U程h获得监视this对象的对象锁Q假设未被锁Q否则线E等待直到锁释放Q?br /> 2. U程内存的数据被消除Q从“?#8221;内存区域中读入(Java虚拟优化此步。。。[后面的不知道怎么表达,汗]Q?br /> 3. 代码块被执行<br /> 4. 对于变量的Q何改变现在可以安全地写到“?#8221;内存区域中(不过geti3()Ҏ不会改变变量|<br /> 5. U程释放监视this对象的对象锁<br /> 因此volatile只是在线E内存和“?#8221;内存间同步某个变量的|而synchronized通过锁定和解锁某个监视器同步所有变量的倹{显然synchronized要比volatile消耗更多资源?/p> <p>附英文原文:<br /> What does volatile do? </p> <p>This is probably best explained by comparing the effects that volatile and synchronized have on a method. volatile is a field modifier, while synchronized modifies code blocks and methods. So we can specify three variations of a simple accessor using those two keywords: </p> <div> <ol ln-show="" title="Double click to hide line number." ondblclick="linenumber(this)"> <li>int<span style="color: Blue;">i1</span><span style="color: Gray;">;              </span>int<span style="color: Blue;">geti1</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i1</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> <li><span style="color: Green;">volatile</span> int<span style="color: Blue;">i2</span><span style="color: Gray;">;              </span>int<span style="color: Blue;">geti2</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i2</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> <li><span style="color: Gray;">         </span>int <span style="color: Blue;">i3</span><span style="color: Gray;">; </span><span style="color: Green;">synchronized</span>int<span style="color: Blue;">geti3</span><span style="color: Olive;">()</span><span style="color: Olive;">{</span><span style="color: Green;">return</span><span style="color: Blue;">i3</span><span style="color: Gray;">;</span><span style="color: Olive;">}</span></li> </ol> </div> <p>geti1() accesses the value currently stored in i1 in the current thread. Threads can have local copies of variables, and the data does not have to be the same as the data held in other threads. In particular, another thread may have updated i1 in it’s thread, but the value in the current thread could be different from that updated value. In fact Java has the idea of a “main” memory, and this is the memory that holds the current “correct” value for variables. Threads can have their own copy of data for variables, and the thread copy can be different from the “main” memory. So in fact, it is possible for the “main” memory to have a value of 1 for i1, for thread1 to have a value of 2 for i1 and for thread2 to have a value of 3 for i1 if thread1 and thread2 have both updated i1 but those updated value has not yet been propagated to “main” memory or other threads. </p> <p>On the other hand, geti2() effectively accesses the value of i2 from “main” memory. A volatile variable is not allowed to have a local copy of a variable that is different from the value currently held in “main” memory. Effectively, a variable declared volatile must have it’s data synchronized across all threads, so that whenever you access or update the variable in any thread, all other threads immediately see the same value. Of course, it is likely that volatile variables have a higher access and update overhead than “plain” variables, since the reason threads can have their own copy of data is for better efficiency. </p> <p>Well if volatile already synchronizes data across threads, what is synchronized for? Well there are two differences. Firstly synchronized obtains and releases locks on monitors which can force only one thread at a time to execute a code block, if both threads use the same monitor (effectively the same object lock). That’s the fairly well known aspect to synchronized. But synchronized also synchronizes memory. In fact synchronized synchronizes the whole of thread memory with “main” memory. So executing geti3() does the following: </p> <p>1. The thread acquires the lock on the monitor for object this (assuming the monitor is unlocked, otherwise the thread waits until the monitor is unlocked).<br /> 2. The thread memory flushes all its variables, i.e. it has all of its variables effectively read from “main” memory (JVMs can use dirty sets to optimize this so that only “dirty” variables are flushed, but conceptually this is the same. See section 17.9 of the Java language specification).<br /> 3. The code block is executed (in this case setting the return value to the current value of i3, which may have just been reset from “main” memory).<br /> 4. (Any changes to variables would normally now be written out to “main” memory, but for geti3() we have no changes.)<br /> 5. The thread releases the lock on the monitor for object this. </p> <p>So where volatile only synchronizes the value of one variable between thread memory and “main” memory, synchronized synchronizes the value of all variables between thread memory and “main” memory, and locks and releases a monitor to boot. Clearly synchronized is likely to have more overhead than volatile.</p> <p>摘自Qhttp://bianbian.org/technology/java/88.html</p> <img src ="http://www.tkk7.com/fingki/aggbug/250106.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fingki/" target="_blank">Fingki.li</a> 2009-01-06 15:24 <a href="http://www.tkk7.com/fingki/archive/2009/01/06/250106.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>有关 this$0 问题http://www.tkk7.com/fingki/archive/2009/01/06/250074.htmlFingki.liFingki.liTue, 06 Jan 2009 04:24:00 GMThttp://www.tkk7.com/fingki/archive/2009/01/06/250074.htmlhttp://www.tkk7.com/fingki/comments/250074.htmlhttp://www.tkk7.com/fingki/archive/2009/01/06/250074.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/250074.htmlhttp://www.tkk7.com/fingki/services/trackbacks/250074.html有synthetic标记的field和method是class内部使用的,正常的源代码里不会出现synthetic field。小颖编译工L的就是jad.所有反~译工具都不能保证完全正地反编译class。所以你不能要求太多?br /> 下面我给大家介绍一下synthetic

下面的例子是最常见的synthetic field
class parent
{
public void foo()
{
}
class inner
{
inner()
{
foo();
}
}
}
非static的inner class里面都会有一个this$0的字D保存它的父对象。编译后的inner class 像下面q样Q?br /> class parent$inner
{
synthetic parent this$0;
parent$inner(parent this$0)
{
this.this$0 = this$0;
this$0.foo();
}
}
所有父对象的非U有成员都通过 this$0来访问?br />
q有许多用到synthetic的地斏V比如用了assert 关键字的class会有一?br /> synthetic static boolean $assertionsDisabled 字段
使用了assert的地?br /> assert condition;
在class里被~译?br /> if(!$assertionsDisabled && !condition)
{
throw new AssertionError();
}

q有Q在jvm里,所有class的私有成员都不允许在其他c里讉KQ包括它的inner class。在java语言里inner class是可以访问父cȝU有成员的。在class里是用如下的Ҏ实现的:
class parent
{
private int value = 0;
synthetic static int access$000(parent obj)
{
return value;
}
}
在inner class里通过access$000来访问value字段?br />
摘自Q?/span>http://www.cjsdn.net/post/print?bid=1&id=130784

Fingki.li 2009-01-06 12:24 发表评论
]]>
Simple Certificate Enrollment Protocol(SCEP)http://www.tkk7.com/fingki/archive/2009/01/04/249732.htmlFingki.liFingki.liSun, 04 Jan 2009 06:25:00 GMThttp://www.tkk7.com/fingki/archive/2009/01/04/249732.htmlhttp://www.tkk7.com/fingki/comments/249732.htmlhttp://www.tkk7.com/fingki/archive/2009/01/04/249732.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/249732.htmlhttp://www.tkk7.com/fingki/services/trackbacks/249732.html IETF Q?http://www.potaroo.net/ietf/idref/draft-nourse-scep/
Java SCEP Q?http://www.urut.ch/scep/
OpenSCEP Q?http://openscep.othello.ch/



Fingki.li 2009-01-04 14:25 发表评论
]]>
关于 Exception: An invalid XML character (Unicode: 0x0) was foundhttp://www.tkk7.com/fingki/archive/2008/09/04/226969.htmlFingki.liFingki.liThu, 04 Sep 2008 07:18:00 GMThttp://www.tkk7.com/fingki/archive/2008/09/04/226969.htmlhttp://www.tkk7.com/fingki/comments/226969.htmlhttp://www.tkk7.com/fingki/archive/2008/09/04/226969.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/226969.htmlhttp://www.tkk7.com/fingki/services/trackbacks/226969.html An invalid XML character (Unicode: 0x0) was found in the element content of the document.

问题描述Q?br /> 当我们用
byte[] info ;
DocumentHelper.parseText(new String(info));
一个字节数l{成字W串再{成DocumentQXML格式Q时Q常怼遇到上述异常?br /> 特别是当字符串有加、解密,或编码等情况时?br />
原因Q?br /> 从异常来看,很明显是因ؓ字节数组中存?Unicode: 0x0,而这个字节在Xml中被认ؓ是非法字W?br />
对于一些经q编码或加、解密的字符串中Q很Ҏ会出现这?0x0,
特别是在加、解密中Q经怼涉及到字W填充,而填充物通常?0x0Q?br /> 需对于0x00-0x20 都会引v一定的问题Q又因ؓq些字符不可见,因此用通常的编辑器q行~辑的时候找不到问题所在?br /> 而在转成String后也觉察不到M异常?br /> 所以在转成XML格式时要对字W串q行:
*  Verify that no character has a hex value greater than 0xFFFD, or less than 0x20.
* Check that the character is not equal to the tab ("t), the newline ("n), the carriage return ("r), or is an invalid XML character below the range of 0x20. If any of these characters occur, an exception is thrown.

pubic void CheckUnicodeString(String value)
    {
    for (int i=0; i < value.Length; ++i) {
        if (value[i] > 0xFFFD)
        {
            throw new Exception("Invalid Unicode");//或者直接替换掉0x0 value[i]='"n';
        }
        else if (value[i] < 0x20 && value[i] != '"t' & value[i] != '"n' & value[i] != '"r')
        {
            throw new Exception("Invalid Xml Characters");//或者直接替换掉0x0 value[i]='"n';
        }
    }

相关资源Q?br /> http://msdn.microsoft.com/en-us/library/k1y7hyy9.aspx
http://gceclub.sun.com.cn/developer/technicalArticles/Intl/Supplementary/index_zh_CN.html



Fingki.li 2008-09-04 15:18 发表评论
]]>
一些关于随机数的理?/title><link>http://www.tkk7.com/fingki/archive/2008/08/28/225442.html</link><dc:creator>Fingki.li</dc:creator><author>Fingki.li</author><pubDate>Thu, 28 Aug 2008 15:46:00 GMT</pubDate><guid>http://www.tkk7.com/fingki/archive/2008/08/28/225442.html</guid><wfw:comment>http://www.tkk7.com/fingki/comments/225442.html</wfw:comment><comments>http://www.tkk7.com/fingki/archive/2008/08/28/225442.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/fingki/comments/commentRss/225442.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/fingki/services/trackbacks/225442.html</trackback:ping><description><![CDATA[<p>以往有听说过“Microsoft Windows、FreeBSD不安全随机数生成器信息泄露漏z?#8221;之类的文章,大都是因为随机函数存在漏z生成不安全的随机,D可预的加密密钥?br /> About Random<br /> 随机数是密码学的一个重要部分,它通常作ؓ初始化向量用于密钥生成中。有许多试Ҏ数字计算l定数字序列的随机性,它们考虑l定数定在序列中出现的周期,做更l致的测量,包括相同数字或其他重复Ş式出现的周期?br /> 但统计随机性的要求与加密随机性不同?br /> 一个数字序列在l计上是随机的,但如果攻击者可以推出数字的序列(通过了解使用的算法和随机U子|Q那么加密是变得不安全了?br /> About Pseudo Random 伪随机数<br /> 对于一串随机的数字Q最常见的描q就是没有从前一个数字推出后一个数字的数学Ҏ。最好的随机数是从物理过E中获得的,因ؓ实际物理E才是真正随机的。事实上Q一些随机数生成器就是用硬件设|来实现Q如音频输入或二极管?br />     从设计上来说Q计机是很定的,因此不是生成随机数的好选择。它们通常求助于一个生成统计上随机的数字串的算法。ؓ了确定在该算法中使用的输入|它们要求用户提供一个种子|q通常来自于系l时钟、网卡MAC地址以及其他不同的系l参数?br />     q些随机数字很适合于计机游戏中的CZ数据或徏模物理过E。不q,它们不适合于加密。它的弱点包括以下几点:<br /> ?nbsp;    伪随机数是周期性的。最l将重复数字序列?br /> ?nbsp;    如果使用相同的种子|接收到序列完全一L“随机”数。因此,随机序列与种子g样多?br /> ?nbsp;    随机数可使用逆向工程。运用算法知识,强力d会立即猜到U子倹{如果种子值和旉之间有相x,d者将会推出所有后面的“随机”数?br />  <br /> 伪随机数是出现许多臭名昭著的d的主要原因。破?6 位DES?997q?月的96 天到1999 q?月的22 时15 分钟,׃DES使用的伪随机数生成算法导致了q个l果Q有一U攻d是针对赌博应用程序,q种应用E序使用一个随机数U子值来对纸牌进行排序,而洗牌的可能性是有限的。在看完开始的几张牌后Q用户可以将当前发的牌与某种可能的洗牌序列匹配,来确定剩下牌的顺序?/p> <p>另一个著名的例子是Netscape Navigator 早期版本中的取决于时间的随机数字生成器,它泄露了动态生成的用于加密q用SSL的会话中数据的密钥?br /> About Random encrypted 加密的随机数<br /> 随机数生成是许多加密操作不可分割的组成部分。例如,加密密钥需要尽可能地随机,以便使它们很难被复制。加密随机数生成器必ȝ成在计算上无法进行推(低于 p < .05 的概率)的输出;卻IM推算下一个输Z的方法不得具有比随机猜测更高的成功几率?br /> Z说明一q串的随机数字是加密安全的,必须使得用户不可能通过计算重新生成同样序列的随机数。遗憄是,q用伪随机数字,可以很容易地重新生成同样的序列。用户需要知道的知识是伪随机数生成器算法和U子倹{?br />     通过加密保护数据Z加密法和更为随机的U子值就是本文要提出的方?一个带加密功能的随机数产生器,可以应用于需要加密随机数的场?Z构成U子|需要用不同的值组合成一个系l范围内的种子倹{这些值包括调用的应用E序可以提供的位Q例如鼠标或键盘动作之间的用户反应时间、象q程ID和线EIDq样的系l和用户数据、系l时钟、系l计数器、自q盘集属和散列的用户环境块。接着使用SHA-1散列q个|输出用于创徏一个随机数据流Q用于更新系l种子|。这可以起作用,是因为散列值生成了看似随机的数据,只改变源文档Q种子|中的一个位QQ何两个输出的散列׃n它们50%的位Q尽两个输出只有一位之差。当Ӟ从理ZԌ有些q程q是周期性的。例如磁盘搜索时间看似随机的Q实际取决于易于定的因素,可以被推出来。ؓ了获取更好的随机数生成,可以采用g生成器,例如Intel的随机数生成器?br />     <br /> 说明Q?br />     创徏加密安全的随机数需要更多的旉Q这意味着如果需要快速地在一个短旉内生成大量随机数Q例如百万的数据)是不适合的。在一个简单测试中Q用本文提到的RNG生成一百万个随机数的时间花费差不多是伪随机数生成器所用时间的八倍之多?br /> <br /> 相关资源Qhttp://www.xfocus.net/articles/200209/451.html<br /> </p> <img src ="http://www.tkk7.com/fingki/aggbug/225442.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/fingki/" target="_blank">Fingki.li</a> 2008-08-28 23:46 <a href="http://www.tkk7.com/fingki/archive/2008/08/28/225442.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java 探测|络资源是否可用http://www.tkk7.com/fingki/archive/2008/07/28/218072.htmlFingki.liFingki.liMon, 28 Jul 2008 07:16:00 GMThttp://www.tkk7.com/fingki/archive/2008/07/28/218072.htmlhttp://www.tkk7.com/fingki/comments/218072.htmlhttp://www.tkk7.com/fingki/archive/2008/07/28/218072.html#Feedback4http://www.tkk7.com/fingki/comments/commentRss/218072.htmlhttp://www.tkk7.com/fingki/services/trackbacks/218072.html 一U方法是调用ping命oQ?br /> 如:
      Process   process=   Runtime.getRuntime().exec("ping   192.168.0.5");  
      InputStreamReader   return   =   new   InputStreamReader(process.getInputStream());  
      LineNumberReader   returnData   =   new   LineNumberReader   (return);    
   
      String   line="";  
      while((line=returnData.readLine())!=null){  
          System.out.println(line);  
      }
通用对返回数据进行分析,来探网l资源的可用性;
q种Ҏ有一个缺点:是许多|络资源是不允许被ping的,从而针对这c资源无法探?br /> 另一U方法是使用URL,
如:
                URL url = new URL("http://localhost");  
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();  
                int state = connection.getResponseCode();  
                String responseContent = connection.getResponseMessage();
通过分析ResponseCode来探网l资源的可用性?br /> 另外Q当指定的网l资源走SSLӞ即用https协议Ӟ需要加入可信证书到trust.keystore.
通常情况下,我的用的是jre的keystoreQcacertsQ如jdk6下的路径为:jdk1.6.0_05/jre/lib/security/cacerts
我们需要把指定资源的数字证书导入到信Q?cacerts.
可以使用keytool工具Qkeytool -import -alias localhost -file localhost.cer -keystore cacerts
如果我们不想使用jre的keystoreQ我们可以徏立自qkeystore,
        System.setProperty("javax.net.ssl.trustStore", "/home/liqingfeng/workspace/Test/mystore/localhost.keystore");
        System.setProperty("javax.net.ssl.trustStorePassword","changeit");
用keytool命o把localhost的证书导入到指定的localhost.keystore中。这h们就可以用URL来探SSL|络资源的可用性了?br />
q里必须注意的是指定|络资源的证书的CNQ必M资源讉K地址一_否则会报错?br /> 以下是常见异常:
当keystore中没有指定资源的证书Ӟ
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
当指定资源证书的CN与资源访问地址不匹配时Q?br /> javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching localhost found







Fingki.li 2008-07-28 15:16 发表评论
]]>
Good Adresshttp://www.tkk7.com/fingki/archive/2008/07/21/216316.htmlFingki.liFingki.liMon, 21 Jul 2008 03:50:00 GMThttp://www.tkk7.com/fingki/archive/2008/07/21/216316.htmlhttp://www.tkk7.com/fingki/comments/216316.htmlhttp://www.tkk7.com/fingki/archive/2008/07/21/216316.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/216316.htmlhttp://www.tkk7.com/fingki/services/trackbacks/216316.htmlGood Address: Command Line Tools for win32  
http://www.vkill.net/tools.html

脚本中心脚本库网址:
http://www.microsoft.com/china/technet/community/scriptcenter/scripts/default.mspx

有关用户和组的脚?扑־我好辛苦呀)
http://www.microsoft.com/china/technet/community/scriptcenter/user/default.mspx

最q发C个不错的jdk6 source|站,收藏一?
http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Modules-sun/security/sun/security/krb5/internal/ktab/KeyTab.java.htm

http://developer.classpath.org/doc/

http://fuseyism.com/classpath/doc/

http://kickjava.com/src/

http://www.docjar.com/

VbScript语言参?br /> http://book.chinaz.com/VBScript/vbsdocs/vbstoc.htm

SUN|站
http://www.java.sun.com
http://java.sun.com/javase/technologies/security/




Fingki.li 2008-07-21 11:50 发表评论
]]>
About JDK6 source http://www.tkk7.com/fingki/archive/2008/07/14/214823.htmlFingki.liFingki.liMon, 14 Jul 2008 13:32:00 GMThttp://www.tkk7.com/fingki/archive/2008/07/14/214823.htmlhttp://www.tkk7.com/fingki/comments/214823.htmlhttp://www.tkk7.com/fingki/archive/2008/07/14/214823.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/214823.htmlhttp://www.tkk7.com/fingki/services/trackbacks/214823.html最q发C个不错的jdk6 source|站,收藏一?
http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Modules-sun/security/sun/security/krb5/internal/ktab/KeyTab.java.htm



Fingki.li 2008-07-14 21:32 发表评论
]]>
About log4jhttp://www.tkk7.com/fingki/archive/2008/06/25/210488.htmlFingki.liFingki.liWed, 25 Jun 2008 04:15:00 GMThttp://www.tkk7.com/fingki/archive/2008/06/25/210488.htmlhttp://www.tkk7.com/fingki/comments/210488.htmlhttp://www.tkk7.com/fingki/archive/2008/06/25/210488.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/210488.htmlhttp://www.tkk7.com/fingki/services/trackbacks/210488.html Log4j有三个主要的lgQLoggersQAppenders和Layouts.
Loggers:日志cd
Appenders日志要输出的地方
Layouts日志以何UŞ式输出?br /> 1.Loggers 日志cd
Loggerslg在此pȝ中被分ؓ五个U别QDEBUG、INFO、WARN、ERROR和FATAL?br /> q五个别是有顺序的QDEBUG < INFO < WARN < ERROR < FATAL
说明Q假设你的LoggerU别为AQ则所有别大于等于A的方法的参数信息都将输出到指定位|?br /> QD个例子更易懂Q如果你的LoggerU别为INFO,则所有用.info(somemessage),.warn(somemessage),.error(somemessage),.fatal(somemessage)Ҏ的参C息都输出到指定位置Q但调用.debug(somemessage)Ҏ参数信息不会输出?br /> 2.Appenders 日志要输出的地方
Log4j日志pȝ允许把日志输出到不同的地方,如控制台QConsoleQ、文ӞFilesQ、根据天数或者文件大生新的文件、以的形式发送到其它地方{等?br /> org.apache.log4j.ConsoleAppenderQ控制台Q?br /> org.apache.log4j.FileAppenderQ文Ӟ
org.apache.log4j.DailyRollingFileAppenderQ每天生一个日志文Ӟ
org.apache.log4j.RollingFileAppenderQ文件大到达指定尺寸的时候生一个新的文Ӟ
org.apache.log4j.WriterAppenderQ将日志信息以流格式发送到L指定的地方)
3.Layouts 日志以何UŞ式输?br /> Layouts提供了四U日志输出样式,如根据HTML样式、自由指定样式、包含日志别与信息的样式和包含日志旉、线E、类别等信息的样式等{?br /> org.apache.log4j.HTMLLayoutQ以HTML表格形式布局Q?br /> org.apache.log4j.PatternLayoutQ可以灵zd指定布局模式Q?br /> org.apache.log4j.SimpleLayoutQ包含日志信息的U别和信息字W串Q?br /> org.apache.log4j.TTCCLayoutQ包含日志生的旉、线E、类别等{信息)

log4j的具体用请参照http://logging.apache.org/log4j/1.2/apidocs/index.html(log4j API)


Fingki.li 2008-06-25 12:15 发表评论
]]>
cvs不能提交 Permission deniedhttp://www.tkk7.com/fingki/archive/2008/06/05/206042.htmlFingki.liFingki.liThu, 05 Jun 2008 06:27:00 GMThttp://www.tkk7.com/fingki/archive/2008/06/05/206042.htmlhttp://www.tkk7.com/fingki/comments/206042.htmlhttp://www.tkk7.com/fingki/archive/2008/06/05/206042.html#Feedback1http://www.tkk7.com/fingki/comments/commentRss/206042.htmlhttp://www.tkk7.com/fingki/services/trackbacks/206042.html ?font size="3">The server reported an error while performing the "cvs commit" command.
ccookteammeal: cvs [server aborted]: cannot rename file /web/***/WebRoot/WEB-INF/,web.xml, to /web/***/WebRoot/WEB-INF/web.xml,v: Permission denied

回想之前用CVS时也遇到q这个经兔R题,用户权限问题Q?br />     问题出现在目录的权限上.我们安装CVS服务器时一般都用的是؜合模式登录,需要windows和CVS共同验证?br /> 要登录CVSQ必d时是CVS用户和WINDOW用户Qƈ且这个用戯对CVS目录有读写权限?br /> 一般我们新建的CVS用户Q默认在WINDOW里只是普通用P对CVS目录只有L限,但没有写权限Q所以可以获取文Ӟ但当CVS 提交commitӞ会报?Permission denied.
    所以,遇到q种情况Q就把你的CVS用户在windowQCVS服务器所在的机器Q上修改为Administrator权限?br /> 在网上又摘录一些问题及解决如下Q?br /> 症状1Q?br /> cvs chacl default:n
cvs [chacl aborted]: server does not support chacl
***** CVS exited normally with code 1 *****
解决Q是python跟wincvs不兼容,最后用python221+cvsnt-2.0.41+wincvs1.3中文?br />
症状2Q无法checkout模块
cvs checkout 大狼的工作目?(in directory E:\CVS\sssss)
cvs server: User user4 cannot access lxwDIR
***** CVS exited normally with code 1 *****
解决Q没有给user4的用h工作目录的读写权?br />
症状3Q无法提交修改,加文件等
cvs commit -m "no message" "新徏 文本文档.txt" (in directory E:\CVS\sssss\zylDIR\)
cvs [server aborted]: "commit" requires write access to the repository
***** CVS exited normally with code 1 *****
解决Q没有把user4加到writers中去

症状4Q无法提交修改,加文件等
cvs add: Empty password used - try 'cvs login' with a real password
cvs [add aborted]: authorization failed: server 192.168.0.105 rejected access to E:/cvs/KHRoot for user user2
***** CVS exited normally with code 1 *****
解决Q应为我用user1用户checkout了模块,但用user2修改文gq提交,或加文gQ重新用user2再在其他目录checkout一下模块,修改提交可以了

症状5Q无法给模块附用?br /> cvs chacl user4:rcw
***** CVS exited normally with code 1 *****
cvs [server aborted]: "chacl" requires write access to the repository
解决Q我用user4d了,只有administrator有此权限





Fingki.li 2008-06-05 14:27 发表评论
]]>
ant 条g判断 conditionhttp://www.tkk7.com/fingki/archive/2008/05/21/201919.htmlFingki.liFingki.liWed, 21 May 2008 07:26:00 GMThttp://www.tkk7.com/fingki/archive/2008/05/21/201919.htmlhttp://www.tkk7.com/fingki/comments/201919.htmlhttp://www.tkk7.com/fingki/archive/2008/05/21/201919.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/201919.htmlhttp://www.tkk7.com/fingki/services/trackbacks/201919.html
    basic elements: istrue isfalse not and or xor available isset equals  filesmatch
    1、istrue isfalse:断言 ??br /> <project name="testCondition">
    <target name="test">
        <condition property="scondition">
            <istrue value="true"/>                   
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>

    2、逻辑q算
    2.1、not 逻辑?nbsp;
<project name="testCondition">
    <target name="test">
        <condition property="scondition">
            Qnot>
                <istrue value="true"/>                   
            </not>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>
    2.2、and 逻辑?br /> <project name="testCondition">
    <target name="test">
        <condition property="scondition">
            Qand>
                <istrue value="true"/>
                <istrue value="false"/>                   
            </and>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>
    2.3、or 逻辑?xor异或 (语法上与andcM)

    3、available 是否可用
<project name="testCondition">
    <path id="all.test.classes">        
         <pathelement location="bin"/>
     </path>
    <target name="test">
        <condition property="scondition">
            <!--在指定的classpath路径下是否存在资?TestTest.class-->
            <available resource="TestTest.class">
                <classpath refid="all.test.classes" />       
            </available>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>

    4、isset 指定属性是否存?br /> <project name="testCondition">
    <!--属性也可以通过ant参数-D来设|?->
    <property name="name" value="this is name"/>   
    <target name="test">
        <condition property="scondition">
            <!--如果属性name不存在则q回false-->
            <isset property="name"/>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>
    5、equals 是否相等
<project name="testCondition">
    <!--属性也可以通过ant参数-D来设|?->
    <property name="name" value="this is name"/>   
    <target name="test">
        <condition property="scondition">
            <!--如果arg1的garg2的值相{返回trueQ否则ؓfalse-->
            <equals arg1="${name}" arg2="this is name"/>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>   
    6、filesmatch 比较文g
<project name="testCondition">       
    <target name="test">
        <condition property="scondition">
            <!--如果file1所代表的文件与file2所代表的文件相{返回trueQ否则ؓfalse-->
            <filesmatch file1="testfile1.txt" file2="testfile2.txt"/>
        </condition>
        <antcall target="isTrue"></antcall>
        <antcall target="isFalse"></antcall>       
    </target>
    <target name="isTrue" if="scondition">
        <echo>is ture</echo>
    </target>
    <target name="isFalse" unless="scondition">
        <echo>is false</echo>
    </target>
</project>   


更多内容可以参?http://ant.apache.org/manual/CoreTasks/conditions.html


Fingki.li 2008-05-21 15:26 发表评论
]]>
Eclipse自动提示功能http://www.tkk7.com/fingki/archive/2008/05/07/198983.htmlFingki.liFingki.liWed, 07 May 2008 07:26:00 GMThttp://www.tkk7.com/fingki/archive/2008/05/07/198983.htmlhttp://www.tkk7.com/fingki/comments/198983.htmlhttp://www.tkk7.com/fingki/archive/2008/05/07/198983.html#Feedback1http://www.tkk7.com/fingki/comments/commentRss/198983.htmlhttp://www.tkk7.com/fingki/services/trackbacks/198983.htmlEclispe自动提示功能讄如下Q?/p>

W一步:

windowsQ?gt;preferences->java->Editor->Code   Assist   ?/p>

autoQactivetion中的Enable auto-activetion选项要勾选上

q里面有个时间的讑֮是ؓ提示代码讑֮的显C时间。你可以Ҏ自己的情况设定?/p>

W二步:

window->Preferences->Java->Editor->Content Assist->Advanced   上面的选项卡Select the proposal kinds contained in the 'default' content assist list: 中把 Other Java Proposals 选项打上勑ְ可以了?/span>

另注Q也可以直接恢复成默认设|?/p>

Fingki.li 2008-05-07 15:26 发表评论
]]>
单步调试 eclipsehttp://www.tkk7.com/fingki/archive/2008/05/06/198702.htmlFingki.liFingki.liTue, 06 May 2008 06:37:00 GMThttp://www.tkk7.com/fingki/archive/2008/05/06/198702.htmlhttp://www.tkk7.com/fingki/comments/198702.htmlhttp://www.tkk7.com/fingki/archive/2008/05/06/198702.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/198702.htmlhttp://www.tkk7.com/fingki/services/trackbacks/198702.html1、单步调试快捷键
以debug方式q行javaE序?br /> QF8Q直接执行程序。遇到断Ҏ暂停Q?br /> QF5Q单步执行程序,遇到Ҏ时进入;
QF6Q单步执行程序,遇到Ҏ时蟩q;
QF7Q单步执行程序,从当前方法蟩出?br />
2?/font>改变变量的?/font>
叛_变量Q在弹出的菜单中选择[change variable value]Q弹Z改画面?br /> 改变其值后Q按下okQ这Ӟ变量的值就改ؓ修改后的g?br /> 3、检查代码段是否正确
选择一句或一D代码,右键单击在弹出的菜单中选择Inspect,
此时Q代码的执行l果显C在ExpressionsH口中?/font>


Fingki.li 2008-05-06 14:37 发表评论
]]>
关于Eclipse:Error logged from Ant UI:http://www.tkk7.com/fingki/archive/2008/03/21/Error_logged_from_Ant_UI.htmlFingki.liFingki.liFri, 21 Mar 2008 08:08:00 GMThttp://www.tkk7.com/fingki/archive/2008/03/21/Error_logged_from_Ant_UI.htmlhttp://www.tkk7.com/fingki/comments/187724.htmlhttp://www.tkk7.com/fingki/archive/2008/03/21/Error_logged_from_Ant_UI.html#Feedback0http://www.tkk7.com/fingki/comments/commentRss/187724.htmlhttp://www.tkk7.com/fingki/services/trackbacks/187724.html     查看Eclipse的Error logQ显C?br />     Error logged from Ant UI:
	Exception Stack Trace:

java.net.SocketTimeoutException: Accept timed out

at java.net.PlainSocketImpl.socketAccept(Native Method)

at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)

at java.net.ServerSocket.implAccept(ServerSocket.java:448)

at java.net.ServerSocket.accept(ServerSocket.java:419)

查看build.xml文g无异常,让我好是奇怪,明明昨天q是正常的呀?br />
后来查看一下Ant Home,发现只有四项Q觉得有点不对劲Q他l一看,居然指到?home/fingki/eclipse/plugins/Axis2_service_Archiver_1.3.0/lib下,

重新指定一下Ant Home,q行antQ运行了?br />
后来研究才发玎ͼ原来之前刚装了Axis2的plugins,Axis2_service_Archiver_1.3.0Q这样Eclipse重启后优先把Ant Home指向那了Q导致ant不工作了?br />
看来Axis2_service_Archiver_1.3.0q个pluginsq是有些bug呀?br />
具体讄Ant Home如下Q在Eclipse中-QwindowQ>preferencesQ>AntQ>RuntimeQ>ClasspathQ点击Ant home按钮Q重新让其指向eclipse中的ant的plugins文g夹处Q?br />
一般都?Eclipse_home%/plugins/org.apache.ant_1.x.x?br />



Fingki.li 2008-03-21 16:08 发表评论
]]>
վ֩ģ壺 һaƵ| ŮĻ| þþƷѹۿ| ްɫɫùۿ| 99þѹƷػ| ؼavëƬѹۿ| þù޵Ӱ| Ļѹۿַ | ҹ޾Ʒվ| þþƷ| ޸Ƶ| þ޹ӰԺվ| 2019Ļ| ձVAĻþõ| ɫAV| ˊ]Ƭѹۿ| ѹۿ | 131ŮëƬ| ֮4δɾ | þѹۿƷ88av| Ʒպһ91| ˳ӰԺ| ҹAVר߲| վ| jŮjڲվ| AVXXX鶹| ޾ƷƵѿ| þĻƷһ| պѹۿ| 91ѹۿվ| aëƬѸëƬƵ| ڳ˾Ʒձ| ˳777߲| ޴߶ר| ޹Ʒľþþ| Ƶվ| **ʵëƬѹۿ| 99ƷƵ߹ۿר| þѹƷ| ĻƷƵ| ɫ޵һ|