??xml version="1.0" encoding="utf-8" standalone="yes"?>国产高清在线不卡,亚洲男人天堂手机在线,97精品在线视频http://www.aygfsteel.com/anchor110/category/45626.htmlzh-cnFri, 20 Apr 2018 16:02:40 GMTFri, 20 Apr 2018 16:02:40 GMT60org.apache.axiom.om.OMException: No meta factory found for feature 'default';错误解决办法http://www.aygfsteel.com/anchor110/articles/433158.html一败涂?/dc:creator>一败涂?/author>Tue, 17 Apr 2018 12:14:00 GMThttp://www.aygfsteel.com/anchor110/articles/433158.htmlhttp://www.aygfsteel.com/anchor110/comments/433158.htmlhttp://www.aygfsteel.com/anchor110/articles/433158.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/433158.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/433158.htmlException in thread "main" org.apache.axiom.om.OMException: No meta factory found for feature 'default'; this usually means that axiom-impl.jar is not in the classpath
        at org.apache.axiom.om.OMAbstractFactory.getMetaFactory(OMAbstractFactory.java:170)
        at org.apache.axiom.om.OMAbstractFactory.getMetaFactory(OMAbstractFactory.java:135)
        at org.apache.axiom.om.OMAbstractFactory.getOMFactory(OMAbstractFactory.java:184)
        at org.apache.axis2.description.AxisDescription.<init>(AxisDescription.java:72)
        at org.apache.axis2.description.AxisService.<init>(AxisService.java:323)
        at org.apache.axis2.description.AxisService.<init>(AxisService.java:394)
        at com.ailk.boss.external.ws.External2Oss_PortTypeServiceStub.populateAxisService(External2Oss_PortTypeServiceStub.java:41)
        at com.ailk.boss.external.ws.External2Oss_PortTypeServiceStub.<init>(External2Oss_PortTypeServiceStub.java:88)
        at com.ailk.boss.external.ws.External2Oss_PortTypeServiceStub.<init>(External2Oss_PortTypeServiceStub.java:77)
        at com.ailk.boss.external.ws.External2Oss_PortTypeServiceStub.<init>(External2Oss_PortTypeServiceStub.java:123)
        at WooEquipmentSend.send2Esb(WooEquipmentSend.java:20)
        at WooPPPoEServiceTest.testGetPPPoEAndSettings(WooPPPoEServiceTest.java:32)
        at WooPPPoEServiceTest.main(WooPPPoEServiceTest.java:18)
解决办法Q?br />1、将pȝ依赖的以下三个jar包版本从1.2.13替换?.2.12卛_Q?br />
axiom-api-1.2.12.jar
axiom-dom-1.2.12.jar
axiom-impl-1.2.12.jar


]]>
Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Objecthttp://www.aygfsteel.com/anchor110/articles/395110.html一败涂?/dc:creator>一败涂?/author>Mon, 04 Feb 2013 07:38:00 GMThttp://www.aygfsteel.com/anchor110/articles/395110.htmlhttp://www.aygfsteel.com/anchor110/comments/395110.htmlhttp://www.aygfsteel.com/anchor110/articles/395110.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/395110.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/395110.html

Error occurred during initialization of VM

java/lang/NoClassDefFoundError: java/lang/Object


问题原因是:(x)jre/lib目录下,~少rt.jar文g?br />
解决办法Q去别的服务器上拯rt.jar卛_?img src ="http://www.aygfsteel.com/anchor110/aggbug/395110.html" width = "1" height = "1" />

]]>
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/CycleRecoverablehttp://www.aygfsteel.com/anchor110/articles/391408.html一败涂?/dc:creator>一败涂?/author>Thu, 15 Nov 2012 20:53:00 GMThttp://www.aygfsteel.com/anchor110/articles/391408.htmlhttp://www.aygfsteel.com/anchor110/comments/391408.htmlhttp://www.aygfsteel.com/anchor110/articles/391408.html#Feedback1http://www.aygfsteel.com/anchor110/comments/commentRss/391408.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/391408.html1、将jaxb-impl-2.1.12.jar和jaxb-api-2.1.jar攑ֈjre/lib/endorsed/目录下,如果没有endorsed目录Q则新徏之,一般情况下是没有的?br />2、将jaxb-impl-2.1.12.jar和jaxb-api-2.1.jar攑ֈ$TOMCAT_HOME/lib/endorsed/目录下,如果没有endorsed目录Q则新徏之,一般情况下是没有的?img src ="http://www.aygfsteel.com/anchor110/aggbug/391408.html" width = "1" height = "1" />

]]>
CountDownLatch的用(注:(x)转蝲于http://www.aygfsteel.com/fanjs2000/archive/2012/10/31/390521.htmlQ?/title><link>http://www.aygfsteel.com/anchor110/articles/390549.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Wed, 31 Oct 2012 09:19:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/390549.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/390549.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/390549.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/390549.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/390549.html</trackback:ping><description><![CDATA[<div>CountDownLatch如其所写,是一个倒计数的锁存器,当计数减?时触发特定的事g。利用这U特性,可以让主U程{待子线E的l束。下面以一个模拟运动员比赛的例子加以说明?/div><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">import</span><span style="color: #000000; "> java.util.concurrent.CountDownLatch;<br /></span><span style="color: #0000FF; ">import</span><span style="color: #000000; "> java.util.concurrent.ExecutorService;<br /></span><span style="color: #0000FF; ">import</span><span style="color: #000000; "> java.util.concurrent.Executors;<br /><br /></span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> Test {<br />    </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">final</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> PLAYER_AMOUNT </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">5</span><span style="color: #000000; ">;<br /><br />    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">static</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> main(String[] args) {        <br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; ">对于每位q动员,CountDownLatch?后即l束比赛</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        CountDownLatch begin </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> CountDownLatch(</span><span style="color: #000000; ">1</span><span style="color: #000000; ">);<br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; ">对于整个比赛Q所有运动员l束后才结?/span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        CountDownLatch end </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> CountDownLatch(PLAYER_AMOUNT);<br />        Player[] plays </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Player[PLAYER_AMOUNT];<br /><br />        </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> i </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #000000; ">0</span><span style="color: #000000; ">; i </span><span style="color: #000000; "><</span><span style="color: #000000; "> PLAYER_AMOUNT; i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)<br />            plays[i] </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Player(i </span><span style="color: #000000; ">+</span><span style="color: #000000; "> </span><span style="color: #000000; ">1</span><span style="color: #000000; ">, begin, end);<br /><br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; ">讄特定的线E池Q大ؓ(f)5</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        ExecutorService exe </span><span style="color: #000000; ">=</span><span style="color: #000000; "> Executors.newFixedThreadPool(PLAYER_AMOUNT);<br />        </span><span style="color: #0000FF; ">for</span><span style="color: #000000; "> (Player p : plays)<br />            exe.execute(p); </span><span style="color: #008000; ">//</span><span style="color: #008000; ">分配U程</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        begin.countDown();<br />        System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Race begins!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />        </span><span style="color: #0000FF; ">try</span><span style="color: #000000; "> {<br />            end.await(); </span><span style="color: #008000; ">//</span><span style="color: #008000; ">{待end状态变?Q即为比赛结?/span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        } </span><span style="color: #0000FF; ">catch</span><span style="color: #000000; "> (InterruptedException e) {<br />            </span><span style="color: #008000; ">//</span><span style="color: #008000; "> TODO: handle exception</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">            e.printStackTrace();<br />        } </span><span style="color: #0000FF; ">finally</span><span style="color: #000000; "> {<br />            System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Race ends!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />        }<br />        exe.shutdown();<br />    }<br />}<br /><br /></span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> Player </span><span style="color: #0000FF; ">implements</span><span style="color: #000000; "> Runnable {<br /><br />    </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> id;<br />    </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> CountDownLatch begin;<br />    </span><span style="color: #0000FF; ">private</span><span style="color: #000000; "> CountDownLatch end;<br /><br />    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> Player(</span><span style="color: #0000FF; ">int</span><span style="color: #000000; "> i, CountDownLatch begin, CountDownLatch end) {<br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; "> TODO Auto-generated constructor stub</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        </span><span style="color: #0000FF; ">super</span><span style="color: #000000; ">();<br />        </span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.id </span><span style="color: #000000; ">=</span><span style="color: #000000; "> i;<br />        </span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.begin </span><span style="color: #000000; ">=</span><span style="color: #000000; "> begin;<br />        </span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.end </span><span style="color: #000000; ">=</span><span style="color: #000000; "> end;<br />    }<br /><br />    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> run() {<br />        </span><span style="color: #008000; ">//</span><span style="color: #008000; "> TODO Auto-generated method stub</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        </span><span style="color: #0000FF; ">try</span><span style="color: #000000; "> {<br />            begin.await(); </span><span style="color: #008000; ">//</span><span style="color: #008000; ">{待begin的状态ؓ(f)0</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">            Thread.sleep((</span><span style="color: #0000FF; ">long</span><span style="color: #000000; ">) (Math.random() </span><span style="color: #000000; ">*</span><span style="color: #000000; "> </span><span style="color: #000000; ">100</span><span style="color: #000000; ">)); </span><span style="color: #008000; ">//</span><span style="color: #008000; ">随机分配旉Q即q动员完成时?/span><span style="color: #008000; "><br /></span><span style="color: #000000; ">            System.out.println(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">Play</span><span style="color: #000000; ">"</span><span style="color: #000000; "> </span><span style="color: #000000; ">+</span><span style="color: #000000; "> id </span><span style="color: #000000; ">+</span><span style="color: #000000; "> </span><span style="color: #000000; ">"</span><span style="color: #000000; "> arrived.</span><span style="color: #000000; ">"</span><span style="color: #000000; ">);<br />        } </span><span style="color: #0000FF; ">catch</span><span style="color: #000000; "> (InterruptedException e) {<br />            </span><span style="color: #008000; ">//</span><span style="color: #008000; "> TODO: handle exception</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">            e.printStackTrace();<br />        } </span><span style="color: #0000FF; ">finally</span><span style="color: #000000; "> {<br />            end.countDown(); </span><span style="color: #008000; ">//</span><span style="color: #008000; ">使end状态减1Q最l减?</span><span style="color: #008000; "><br /></span><span style="color: #000000; ">        }<br />    }<br />}</span></div><img src ="http://www.aygfsteel.com/anchor110/aggbug/390549.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2012-10-31 17:19 <a href="http://www.aygfsteel.com/anchor110/articles/390549.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>synchronized(this) 解释http://www.aygfsteel.com/anchor110/articles/388699.html一败涂?/dc:creator>一败涂?/author>Thu, 27 Sep 2012 08:03:00 GMThttp://www.aygfsteel.com/anchor110/articles/388699.htmlhttp://www.aygfsteel.com/anchor110/comments/388699.htmlhttp://www.aygfsteel.com/anchor110/articles/388699.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/388699.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/388699.htmlpublic class DemoThread implements Runnable {
   
public void run() {
        synchronized(this) {            //请问q里的this怎样理解Qt1和t2的地址不是不一样嘛Q怎么?x)只有一个线E运行?Q?
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() 
+ " synchronized loop " + i); 
            }
         }
    }

    public static void main(String[] args) {
        DemoThread t1 
= new DemoThread();
        Thread ta 
= new Thread(t1, "A");
        Thread tb 
= new Thread(t1, "B");
        ta.start();
        tb.start(); 
    }
}


    解释Q?br />    q里的this是指当前对象,也就是说不管taq是tb,刚开始运行这D代码的时候会(x)l这D代码加个锁,q样即ɘq行C间被替换?
另一个线E也不会(x)执行q段代码,因ؓ(f)q段代码加锁?而钥匙在l代码加锁的那个U程手里,只有加锁的线E运行完q段代码,才会(x)l代码解?
然后其他U程才能执行q段代码.. 加个synchronized(this)以后q行l果是这?
A synchronized loop 0
A synchronized loop 1
A synchronized loop 2
A synchronized loop 3
A synchronized loop 4
B synchronized loop 0
B synchronized loop 1
B synchronized loop 2
B synchronized loop 3
B synchronized loop 4

不加的话是这?(序׃,有好多种l果,q里只是其中一U?..
A synchronized loop 0
B synchronized loop 0
A synchronized loop 1
B synchronized loop 1
A synchronized loop 2
B synchronized loop 2
A synchronized loop 3
B synchronized loop 3
B synchronized loop 4
A synchronized loop 4




       

]]>
javaU程q行机制http://www.aygfsteel.com/anchor110/articles/379874.html一败涂?/dc:creator>一败涂?/author>Sun, 03 Jun 2012 14:09:00 GMThttp://www.aygfsteel.com/anchor110/articles/379874.htmlhttp://www.aygfsteel.com/anchor110/comments/379874.htmlhttp://www.aygfsteel.com/anchor110/articles/379874.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/379874.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/379874.html阅读全文

]]>
Arrays.asList使用http://www.aygfsteel.com/anchor110/articles/362588.html一败涂?/dc:creator>一败涂?/author>Thu, 03 Nov 2011 02:18:00 GMThttp://www.aygfsteel.com/anchor110/articles/362588.htmlhttp://www.aygfsteel.com/anchor110/comments/362588.htmlhttp://www.aygfsteel.com/anchor110/articles/362588.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/362588.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/362588.html1 String[] strings = {"xujiaolin""chengsk""caisiming"};
2 List<String> list = Arrays.asList(strings);
3 System.out.println(list.size());

]]>
java final关键解释http://www.aygfsteel.com/anchor110/articles/362585.html一败涂?/dc:creator>一败涂?/author>Thu, 03 Nov 2011 02:02:00 GMThttp://www.aygfsteel.com/anchor110/articles/362585.htmlhttp://www.aygfsteel.com/anchor110/comments/362585.htmlhttp://www.aygfsteel.com/anchor110/articles/362585.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/362585.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/362585.html
解释如下Q?br />1、如果此对象指向一个常量:(x)
     例如Qfinal int a = 100;那么a的值永q是100?br />     后箋如果重新赋|会(x)报编译错误:(x)a = 200;

2、如果此对象指向一个变量:(x)
     例如Qfinal User admin = new User("administrator");那么代表adminq个对象引用不可改变。但是却可以改变他的属性倹{?br />    
     以下语句~译正确Q?br />     admin.setName("admin");

     以下语句~译错误Q?br />     admin = new User("zhangsan");

]]>
HttpUrlConnection通过代理讉K|络Q{Qhttp://www.iteye.com/problems/38978Q?/title><link>http://www.aygfsteel.com/anchor110/articles/360413.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Mon, 10 Oct 2011 09:52:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/360413.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/360413.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/360413.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/360413.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/360413.html</trackback:ping><description><![CDATA[<div><ol start="1"><li><span>import java.io.IOException;   </span></li><li><span>import java.io.InputStream;   </span></li><li><span>import java.net.InetSocketAddress;   </span></li><li><span>import java.net.MalformedURLException;   </span></li><li><span>import java.net.Proxy;   </span></li><li><span>import java.net.ProxySelector;   </span></li><li><span>import java.net.SocketAddress;   </span></li><li><span>import java.net.URI;   </span></li><li><span>import java.net.URISyntaxException;   </span></li><li><span>import java.net.URL;   </span></li><li><span>import java.net.URLConnection;   </span></li><li><span>import java.util.List;   </span></li><li><span>import java.util.Properties;   </span></li><li>  </li><li><span>public class NetProxy   </span></li><li>{   </li><li><span>// 试本地JVM的网l缺省配|?nbsp;  </span></li><li><span>public void setLocalProxy()   </span></li><li>{   </li><li>Properties prop = System.getProperties();   </li><li><span>//讄http讉K要用的代理服务器的地址   </span></li><li>prop.setProperty(<span>"http.proxyHost", "10.10.0.96");   </span></li><li><span>//讄http讉K要用的代理服务器的端口   </span></li><li>prop.setProperty(<span>"http.proxyPort", "8080");   </span></li><li><span>//讄不需要通过代理服务器访问的LQ可以?通配W,多个地址用|分隔   </span></li><li>prop.setProperty(<span>"http.nonProxyHosts", "localhost|10.10.*");   </span></li><li>  </li><li><span>//讄安全讉K使用的代理服务器地址与端?nbsp;  </span></li><li><span>//它没有https.nonProxyHosts属性,它按照http.nonProxyHosts 中设|的规则讉K   </span></li><li>prop.setProperty(<span>"https.proxyHost", "10.10.0.96");   </span></li><li>prop.setProperty(<span>"https.proxyPort", "443");   </span></li><li>  </li><li><span>//使用ftp代理服务器的L、端口以?qing)不需要用ftp代理服务器的L   </span></li><li>prop.setProperty(<span>"ftp.proxyHost", "10.10.0.96");   </span></li><li>prop.setProperty(<span>"ftp.proxyPort", "2121");   </span></li><li>prop.setProperty(<span>"ftp.nonProxyHosts", "localhost|10.10.*");   </span></li><li>  </li><li><span>//socks代理服务器的地址与端?nbsp;  </span></li><li>prop.setProperty(<span>"socksProxyHost", "10.10.0.96");   </span></li><li>prop.setProperty(<span>"socksProxyPort", "1080");   </span></li><li>}   </li><li>  </li><li><span>// 清除proxy讄   </span></li><li><span>public void removeLocalProxy()   </span></li><li>{   </li><li>Properties prop = System.getProperties();   </li><li>prop.remove(<span>"http.proxyHost");   </span></li><li>prop.remove(<span>"http.proxyPort");   </span></li><li>prop.remove(<span>"http.nonProxyHosts");   </span></li><li>  </li><li>prop.remove(<span>"https.proxyHost");   </span></li><li>prop.remove(<span>"https.proxyPort");   </span></li><li>  </li><li>prop.remove(<span>"ftp.proxyHost");   </span></li><li>prop.remove(<span>"ftp.proxyPort");   </span></li><li>prop.remove(<span>"ftp.nonProxyHosts");   </span></li><li>  </li><li>prop.remove(<span>"socksProxyHost");   </span></li><li>prop.remove(<span>"socksProxyPort");   </span></li><li>}   </li><li>  </li><li><span>//   </span></li><li>  </li><li><span>// 试http   </span></li><li><span>public void showHttpProxy(Object... proxy)   </span></li><li>{   </li><li>URL url = <span>null;   </span></li><li><span>try   </span></li><li>{   </li><li>url = <span>new URL("http://blog.csdn.com/smallnest");   </span></li><li>}   </li><li><span>catch (MalformedURLException e)   </span></li><li>{   </li><li><span>return;   </span></li><li>}   </li><li><span>try   </span></li><li>{   </li><li>URLConnection conn = <span>null;   </span></li><li><span>switch (proxy.length)   </span></li><li>{   </li><li><span>case 0:   </span></li><li>conn = url.openConnection();   </li><li><span>break;   </span></li><li><span>case 1:   </span></li><li>conn = url.openConnection((Proxy) proxy[<span>0]);   </span></li><li><span>break;   </span></li><li><span>default:   </span></li><li><span>break;   </span></li><li>}   </li><li>  </li><li><span>if (conn == null)   </span></li><li><span>return;   </span></li><li>  </li><li>conn.setConnectTimeout(<span>3000); // 讄q接时旉   </span></li><li>InputStream in = conn.getInputStream();   </li><li><span>byte[] b = new byte[1024];   </span></li><li><span>try   </span></li><li>{   </li><li><span>while (in.read(b) > 0)   </span></li><li>{   </li><li>System.out.println(<span>new String(b));   </span></li><li>}   </li><li>}   </li><li><span>catch (IOException e1)   </span></li><li>{   </li><li>}   </li><li>}   </li><li><span>catch (IOException e1)   </span></li><li>{   </li><li>e1.printStackTrace();   </li><li>}   </li><li>  </li><li>}   </li><li>  </li><li><span>// 试ftp   </span></li><li><span>public void showFtpProxy(Object... proxy)   </span></li><li>{   </li><li>URL url = <span>null;   </span></li><li><span>try   </span></li><li>{   </li><li>url = <span>new URL("ftp://ftp.tsinghua.edu.cn");   </span></li><li>}   </li><li><span>catch (MalformedURLException e)   </span></li><li>{   </li><li><span>return;   </span></li><li>}   </li><li><span>try   </span></li><li>{   </li><li>URLConnection conn = <span>null;   </span></li><li><span>switch (proxy.length)   </span></li><li>{   </li><li><span>case 0:   </span></li><li>conn = url.openConnection();   </li><li><span>break;   </span></li><li><span>case 1:   </span></li><li>conn = url.openConnection((Proxy) proxy[<span>0]);   </span></li><li><span>break;   </span></li><li><span>default:   </span></li><li><span>break;   </span></li><li>}   </li><li>  </li><li><span>if (conn == null)   </span></li><li><span>return;   </span></li><li>  </li><li>conn.setConnectTimeout(<span>3000); // 讄q接时旉   </span></li><li>InputStream in = conn.getInputStream();   </li><li><span>byte[] b = new byte[1024];   </span></li><li><span>try   </span></li><li>{   </li><li><span>while (in.read(b) > 0)   </span></li><li>{   </li><li>System.out.println(<span>new String(b));   </span></li><li>}   </li><li>}   </li><li><span>catch (IOException e1)   </span></li><li>{   </li><li>}   </li><li>}   </li><li><span>catch (IOException e1)   </span></li><li>{   </li><li>e1.printStackTrace();   </li><li>}   </li><li>  </li><li>}   </li><li>  </li><li><span>// 得到一个proxy   </span></li><li><span>public Proxy getProxy(Proxy.Type type, String host, int port)   </span></li><li>{   </li><li>SocketAddress addr = <span>new InetSocketAddress(host,port);   </span></li><li>Proxy typeProxy = <span>new Proxy(type, addr);   </span></li><li><span>return typeProxy;   </span></li><li>}   </li><li>  </li><li><span>public static void main(String[] args)   </span></li><li>{   </li><li>NetProxy proxy = <span>new NetProxy();   </span></li><li><span>//试代理服务?nbsp;  </span></li><li>proxy.setLocalProxy();   </li><li>proxy.showHttpProxy();   </li><li>  </li><li><span>//下面两行是清除系l属性,而通过ProxycL定代理服务器   </span></li><li><span>// proxy.removeLocalProxy   </span></li><li><span>//proxy.showHttpProxy(proxy.getProxy(Proxy.Type.SOCKS,"10.10.0.96",1080));   </span></li><li>  </li><li>  </li><li>}   </li><li>}  <br /></li></ol></div><img src ="http://www.aygfsteel.com/anchor110/aggbug/360413.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2011-10-10 17:52 <a href="http://www.aygfsteel.com/anchor110/articles/360413.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.net.ProtocolExceptionhttp://www.aygfsteel.com/anchor110/articles/355875.html一败涂?/dc:creator>一败涂?/author>Fri, 05 Aug 2011 07:53:00 GMThttp://www.aygfsteel.com/anchor110/articles/355875.htmlhttp://www.aygfsteel.com/anchor110/comments/355875.htmlhttp://www.aygfsteel.com/anchor110/articles/355875.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/355875.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/355875.html做androidd功能Ӟ向服务器发送一个登录验证请求,利用的通信是自己包装的http通信c,里面有代码如下:(x)
URL url = new URL(reqAddress);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(6000);
conn.setRequestMethod("post");

一q行Qlogcat报错如下Q?br />
java.net.ProtocolException


解决办法Q?br />修改post为大写POST?br />
说明Q?br />

httpURLConnection.setRequestMethod("POST");

setRequestMethodҎ(gu)的参数值必d?例如GET,POST{?




]]>
tomcat日志U色问题解决办法http://www.aygfsteel.com/anchor110/articles/355732.html一败涂?/dc:creator>一败涂?/author>Thu, 04 Aug 2011 02:43:00 GMThttp://www.aygfsteel.com/anchor110/articles/355732.htmlhttp://www.aygfsteel.com/anchor110/comments/355732.htmlhttp://www.aygfsteel.com/anchor110/articles/355732.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/355732.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/355732.html在eclipse中启动tomcatӞ在console中输出的日志信息为红Ԍ但其实程序ƈ没有错误?br />
原因是:(x)tomcat默认的日志输出按jdk中的System.err来输出,而System.err在eclipse中,以红色显C?br />
解决办法Q?br />Eclipse ?System.err 的显C颜色可以通过 Window --> Preference --> Run/Debug --> Console ?Standard Error text color q行更改?br />
JDK 日志具体的输出处理类需要在 %JRE_HOME%/lib/logging.properties 配置?handlers 指定Q可以? System.out 重写一?java.util.logging.ConsoleHandler 配置q去可以了?/div>

]]>
Java获得一个字W的Ascii?/title><link>http://www.aygfsteel.com/anchor110/articles/353702.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Tue, 05 Jul 2011 05:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/353702.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/353702.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/353702.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/353702.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/353702.html</trackback:ping><description><![CDATA[char a = 'a';<br />int aAscii = a;<br />System.out.println(aAscii);<img src ="http://www.aygfsteel.com/anchor110/aggbug/353702.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2011-07-05 13:04 <a href="http://www.aygfsteel.com/anchor110/articles/353702.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.net.SocketException: Unexpected end of file from serverhttp://www.aygfsteel.com/anchor110/articles/348867.html一败涂?/dc:creator>一败涂?/author>Sat, 23 Apr 2011 07:28:00 GMThttp://www.aygfsteel.com/anchor110/articles/348867.htmlhttp://www.aygfsteel.com/anchor110/comments/348867.htmlhttp://www.aygfsteel.com/anchor110/articles/348867.html#Feedback8http://www.aygfsteel.com/anchor110/comments/commentRss/348867.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/348867.html java.net.SocketException: Unexpected end of file from server
 at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:741)
 at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
 at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:738)
 at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:961)

莫名奇妙Q明明头天在公司是可以用的?br /> 在网上搜索了一下,说可能是|络限制造成的。我l合自己所在网l的情况Q发觉是有这情况。把|络Ҏ(gu)跟外面一L(fng)后,问题解决?br />


]]>
使用java实现|络传输数据的压~(来源|络Q?/title><link>http://www.aygfsteel.com/anchor110/articles/348441.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Sun, 17 Apr 2011 07:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/348441.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/348441.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/348441.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/348441.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/348441.html</trackback:ping><description><![CDATA[import   java.io.*; <br /> import   java.util.zip.*; <br /> <br /> public   class   GZIProc   { <br />     public   static   void   main(String[]   args)   { <br />         <br />         byte[]   b1   ,b2   =   null; <br />         try   { <br />           <br />             BufferedInputStream   in   =   new   BufferedInputStream(   new   FileInputStream(args[0])); <br />             ByteArrayOutputStream   bout   =   new   ByteArrayOutputStream(); <br />             GZIPOutputStream   out   =   new   GZIPOutputStream(bout); <br />             ObjectOutputStream   oout   =   new   ObjectOutputStream(out); <br />             //   d源文?<br />             b1   =   new   byte[in.available()];     <br />             in.read(b1,0,b1.length);             <br />             System.out.println( "压羃?\n "   +   new   String(b1)); <br />                         <br />             //   压羃 <br />             //out.write(b1,0,   b1.length); <br />             oout.writeObject(new   String(b1)); <br />             oout.flush(); <br />             oout.close(); <br />             <br />             //   d压羃字节?<br />             b2   =   bout.toByteArray(); <br />             <br />             System.out.println( "压羃?\n "   +   new   String(b2)); <br />             //   关闭数据?<br />             in.close(); <br />                   <br />             //   解压 <br />             ObjectInputStream   in2   =   new   ObjectInputStream(new   GZIPInputStream(new   ByteArrayInputStream(b2))); <br />             byte[]   b3   =   ((String)in2.readObject()).getBytes(); <br />             in2.close(); <br />             <br />             //   输出 <br />             System.out.println(   new   String(b3)); <br />         }   catch(Exception   e)   { <br />             e.printStackTrace(); <br />         } <br />     } <br /> } <br /> <img src ="http://www.aygfsteel.com/anchor110/aggbug/348441.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2011-04-17 15:59 <a href="http://www.aygfsteel.com/anchor110/articles/348441.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javaInputStream转ؓ(f)byte数组的方?/title><link>http://www.aygfsteel.com/anchor110/articles/343500.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Tue, 25 Jan 2011 06:44:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/343500.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/343500.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/343500.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/343500.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/343500.html</trackback:ping><description><![CDATA[<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #000000;">ByteArrayOutputStream baos </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> ByteArrayOutputStream();<br /> </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> len </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br /> </span><span style="color: #0000ff;">byte</span><span style="color: #000000;">[] b </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> </span><span style="color: #0000ff;">byte</span><span style="color: #000000;">[</span><span style="color: #000000;">1024</span><span style="color: #000000;">];<br /> </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> ((len </span><span style="color: #000000;">=</span><span style="color: #000000;"> is.read(b, </span><span style="color: #000000;">0</span><span style="color: #000000;">, b.length)) </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">) {                     <br />     baos.write(b, </span><span style="color: #000000;">0</span><span style="color: #000000;">, len);<br /> }<br /> </span><span style="color: #0000ff;">byte</span><span style="color: #000000;">[] buffer </span><span style="color: #000000;">=</span><span style="color: #000000;">  baos.toByteArray();</span></div> <img src ="http://www.aygfsteel.com/anchor110/aggbug/343500.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2011-01-25 14:44 <a href="http://www.aygfsteel.com/anchor110/articles/343500.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.net.URL处理中文URLQ导致java.io.FileNotFoundExceptionhttp://www.aygfsteel.com/anchor110/articles/342456.html一败涂?/dc:creator>一败涂?/author>Thu, 06 Jan 2011 13:57:00 GMThttp://www.aygfsteel.com/anchor110/articles/342456.htmlhttp://www.aygfsteel.com/anchor110/comments/342456.htmlhttp://www.aygfsteel.com/anchor110/articles/342456.html#Feedback1http://www.aygfsteel.com/anchor110/comments/commentRss/342456.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/342456.html     URL url = new URL("http://***/中国.doc");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    执行以上代码Ӟ?x)报java.io.FileNotFoundException异常?br />     l查Q发现是url地址含中文问题导致的?br />
解决办法Q?br />     对中文部分进行encode,具体如下Q?br />     URL url = new URL("http://***/" + java.net.URLEncoder.encode("中国") + ".doc");


]]>
JAVA解析XML字符?/title><link>http://www.aygfsteel.com/anchor110/articles/342312.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Tue, 04 Jan 2011 13:57:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/342312.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/342312.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/342312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/342312.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/342312.html</trackback:ping><description><![CDATA[<div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #008080;">1</span> <span style="color: #000000;">DocumentBuilderFactory docBuilderFactory </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">2</span> <span style="color: #000000;">DocumentBuilder docBuilder </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">3</span> <span style="color: #000000;">Document doc </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br /> </span><span style="color: #008080;">4</span> <span style="color: #000000;">docBuilderFactory </span><span style="color: #000000;">=</span><span style="color: #000000;"> DocumentBuilderFactory.newInstance();<br /> </span><span style="color: #008080;">5</span> <span style="color: #000000;">docBuilder </span><span style="color: #000000;">=</span><span style="color: #000000;"> docBuilderFactory.newDocumentBuilder();<br /> </span><span style="color: #008080;">6</span> <span style="color: #000000;">InputStream inputStream </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> ByteArrayInputStream(xml.getBytes());</span><span style="color: #008000;">//</span><span style="color: #008000;">xml解析的字W串</span><span style="color: #008000;"><br /> </span><span style="color: #008080;">7</span> <span style="color: #000000;">doc </span><span style="color: #000000;">=</span><span style="color: #000000;"> docBuilder.parse(inputStream);</span></div> <img src ="http://www.aygfsteel.com/anchor110/aggbug/342312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2011-01-04 21:57 <a href="http://www.aygfsteel.com/anchor110/articles/342312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>16q制字符串{换成数字cdhttp://www.aygfsteel.com/anchor110/articles/342168.html一败涂?/dc:creator>一败涂?/author>Sun, 02 Jan 2011 11:57:00 GMThttp://www.aygfsteel.com/anchor110/articles/342168.htmlhttp://www.aygfsteel.com/anchor110/comments/342168.htmlhttp://www.aygfsteel.com/anchor110/articles/342168.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/342168.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/342168.htmlpublic class Test {
   
public static void main(String[] args) {
       String s 
= "0x40";
       
int b = Integer.parseInt(s.replaceAll("^0[x|X]"""), 16);
       System.out.println((
char)b);
       }
  }


]]>
java中用MD5加密法q行加密(注:(x)转蝲于http://school.cfan.com.cn/pro/java/2007-06-11/1181531460d67777.shtml)http://www.aygfsteel.com/anchor110/articles/341737.html一败涂?/dc:creator>一败涂?/author>Tue, 28 Dec 2010 03:10:00 GMThttp://www.aygfsteel.com/anchor110/articles/341737.htmlhttp://www.aygfsteel.com/anchor110/comments/341737.htmlhttp://www.aygfsteel.com/anchor110/articles/341737.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/341737.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/341737.html    Q一Q消息摘要简?/strong>

    一个消息摘要就是一个数据块的数字指UV即对一个Q意长度的一个数据块q行计算Q生一个唯一指印Q对于SHA1是生一?0字节的二q制数组Q。消? 摘要是一U与消息认证码结合用以保消息完整性的技术。主要用单向散列函数算法,可用于检验消息的完整性,和通过散列密码直接以文本Ş式保存等Q目? q泛使用的算法有MD4、MD5、SHA-1.

    消息摘要有两个基本属性:(x)

    两个不同的报文难以生成相同的摘要难以Ҏ(gu)定的摘要生成一个报文,而可以由该报文反推算指定的摘要代表:(x)国国家标准技术研I所的SHA1和麻省理工学院Ronald Rivest提出的MD5

    Q二Q对字符串进行加?/strong>

    /** *//**利用MD5q行加密
     * @param str  待加密的字符?br />      * @return  加密后的字符?br />      * @throws NoSuchAlgorithmException  没有q种产生消息摘要的算?br />      * @throws UnsupportedEncodingException  
     */
    public String EncoderByMd5(String str) throws NoSuchAlgorithmException, 
UnsupportedEncodingException...{
        //定计算Ҏ(gu)
        MessageDigest md5=MessageDigest.getInstance("MD5");
        BASE64Encoder base64en = new BASE64Encoder();
        //加密后的字符?br />         String newstr=base64en.encode(md5.digest(str.getBytes("utf-8")));
        return newstr;
    }

    调用函数QString str="0123456789"

     System.out.printlnQEncoderByMd5QstrQ)Q?/p>

    输出QeB5eJF1ptWaXm4bijSPyxw==

    Q三Q验证密码是否正?/strong>

    因ؓ(f)MD5是基于消息摘要原理的Q消息摘要的基本特征是很难Ҏ(gu)摘要推算出消息报文,因此要验证密码是否正,必d输入密码Q消息报文)重新计算? 摘要Q和数据库中存储的摘要进行对比(x据库中存储的其实为用户密码的摘要Q,若两个摘要相同,则说明密码正,不同Q则说明密码错误?br />

    /** *//**判断用户密码是否正确
     * @param newpasswd  用户输入的密?br />      * @param oldpasswd  数据库中存储的密码-Q用户密码的摘要
     * @return
     * @throws NoSuchAlgorithmException
     * @throws UnsupportedEncodingException
     */
    public boolean checkpassword(String newpasswd,String oldpasswd) throws NoSuchAlgorithmException, 
UnsupportedEncodingException...{
        if(EncoderByMd5(newpasswd).equals(oldpasswd))
            return true;
        else
            return false;
    }


]]>
java 获取文g夹大,文g大小Q文件个?注:(x)转蝲于http://blog.sina.com.cn/s/blog_45096c6a0100btse.html)http://www.aygfsteel.com/anchor110/articles/341284.html一败涂?/dc:creator>一败涂?/author>Tue, 21 Dec 2010 16:18:00 GMThttp://www.aygfsteel.com/anchor110/articles/341284.htmlhttp://www.aygfsteel.com/anchor110/comments/341284.htmlhttp://www.aygfsteel.com/anchor110/articles/341284.html#Feedback2http://www.aygfsteel.com/anchor110/comments/commentRss/341284.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/341284.htmlpackage tony;


import java.io.File;
import java.text.DecimalFormat;
import java.io.FileInputStream;

public class GetFileSize
{
    public long getFileSizes(File f) throws Exception{//取得文g大小
        long s=0;
        if (f.exists()) {
            FileInputStream fis = null;
            fis = new FileInputStream(f);
           s= fis.available();
        } else {
            f.createNewFile();
            System.out.println("文g不存?);
        }
        return s;
    }
    // 递归
    public long getFileSize(File f)throws Exception//取得文g夹大?br />     {
        long size = 0;
        File flist[] = f.listFiles();
        for (int i = 0; i < flist.length; i++)
        {
            if (flist[i].isDirectory())
            {
                size = size + getFileSize(flist[i]);
            } else
            {
                size = size + flist[i].length();
            }
        }
        return size;
    }

    public String FormetFileSize(long fileS) {//转换文g大小
        DecimalFormat df = new DecimalFormat("#.00");
        String fileSizeString = "";
        if (fileS < 1024) {
            fileSizeString = df.format((double) fileS) + "B";
        } else if (fileS < 1048576) {
            fileSizeString = df.format((double) fileS / 1024) + "K";
        } else if (fileS < 1073741824) {
            fileSizeString = df.format((double) fileS / 1048576) + "M";
        } else {
            fileSizeString = df.format((double) fileS / 1073741824) + "G";
        }
        return fileSizeString;
    }
   
    public long getlist(File f){//递归求取目录文g个数
        long size = 0;
        File flist[] = f.listFiles();
        size=flist.length;
        for (int i = 0; i < flist.length; i++) {
            if (flist[i].isDirectory()) {
                size = size + getlist(flist[i]);
                size--;
            }
        }
        return size;

 

   }
   
    public static void main(String args[])
    {
        GetFileSize g = new GetFileSize();
        long startTime = System.currentTimeMillis();
        try
        {
            long l = 0;
            String path = "C:\\WINDOWS";
            File ff = new File(path);
            if (ff.isDirectory()) { //如果路径是文件夹的时?br />                 System.out.println("文g个数           " + g.getlist(ff));
                System.out.println("目录");
                l = g.getFileSize(ff);
                System.out.println(path + "目录的大ؓ(f)Q? + g.FormetFileSize(l));
            } else {
                System.out.println("     文g个数           1");
                System.out.println("文g");
                l = g.getFileSizes(ff);
                System.out.println(path + "文g的大ؓ(f)Q? + g.FormetFileSize(l));
            }
           
        } catch (Exception e)
        {
            e.printStackTrace();
        }
        long endTime = System.currentTimeMillis();
        System.out.println("dp旉为:(x)" + (endTime - startTime) + "毫秒...");
    }
}



]]>
Class.getResourceAsStream和ClassLoader.getResourceAsStream(注:(x)转蝲于http://dev.firnow.com/course/3_program/java/javajs/20090208/154974.html)http://www.aygfsteel.com/anchor110/articles/340079.html一败涂?/dc:creator>一败涂?/author>Wed, 08 Dec 2010 09:02:00 GMThttp://www.aygfsteel.com/anchor110/articles/340079.htmlhttp://www.aygfsteel.com/anchor110/comments/340079.htmlhttp://www.aygfsteel.com/anchor110/articles/340079.html#Feedback1http://www.aygfsteel.com/anchor110/comments/commentRss/340079.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/340079.html 和classpath中的jar?

两个Ҏ(gu)的区别是资源的定义不同, 一个主要用于相对与一个object取资源,而另一个用于取相对于classpath?br /> 资源Q用的是l对路径?br />
在用Class.getResourceAsStream Ӟ 资源路径有两U方式, 一U以 / 开_(d)则这L(fng)路径是指定绝?br /> 路径Q?如果不以 / 开_(d) 则\径是相对与这个class所在的包的?

在用ClassLoader.getResourceAsStreamӞ 路径直接使用相对于classpath的绝对\径?

举例Q下面的三个语句Q实际结果是一L(fng)Q?
com.explorers.Test.class.getResourceAsStream("abc.jpg")
com.explorers.Test.class.getResourceAsStream("/com/explorers/abc.jpg")
ClassLoader.getResourceAsStream("com/explorers/abc.jpg")

]]>
用Java实现ZIP压羃文g和目录程序代?注:(x)转蝲于http://www.javaweb.cc/language/java/222365.shtml)http://www.aygfsteel.com/anchor110/articles/339914.html一败涂?/dc:creator>一败涂?/author>Mon, 06 Dec 2010 09:13:00 GMThttp://www.aygfsteel.com/anchor110/articles/339914.htmlhttp://www.aygfsteel.com/anchor110/comments/339914.htmlhttp://www.aygfsteel.com/anchor110/articles/339914.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/339914.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/339914.html用Java实现zip压羃文g和目录程序代?/strong>

今天写了个用java压羃的功能,可以实现Ҏ(gu)件和目录的压~?/p>

׃java.util.zip.ZipOutputStream有中文ؕ码问题,所以采用org.apache.tools.zip.ZipOutputStream?
以下是代码:(x)
Java代码
package net.szh.zip;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.CRC32;
import java.util.zip.CheckedOutputStream;

import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;

public class ZipCompressor {
static final int BUFFER = 8192;

private File zipFile;

public ZipCompressor(String pathName) {
zipFile = new File(pathName);
}

public void compress(String srcPathName) {
File file = new File(srcPathName);
if (!file.exists())
throw new RuntimeException(srcPathName + "不存在!");
try {
FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream,
new CRC32());
ZipOutputStream out = new ZipOutputStream(cos);
String basedir = "";
compress(file, out, basedir);
out.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private void compress(File file, ZipOutputStream out, String basedir) {
/* 判断是目录还是文?*/
if (file.isDirectory()) {
System.out.println("压羃Q? + basedir + file.getName());
this.compressDirectory(file, out, basedir);
} else {
System.out.println("压羃Q? + basedir + file.getName());
this.compressFile(file, out, basedir);
}
}

/** 压羃一个目?*/
private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
if (!dir.exists())
return;

File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
/* 递归 */
compress(files[i], out, basedir + dir.getName() + "/");
}
}

/** 压羃一个文?*/
private void compressFile(File file, ZipOutputStream out, String basedir) {
if (!file.exists()) {
return;
}
try {
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(file));
ZipEntry entry = new ZipEntry(basedir + file.getName());
out.putNextEntry(entry);
int count;
byte data[] = new byte[BUFFER];
while ((count = bis.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
bis.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

package net.szh.zip;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.CRC32;
import java.util.zip.CheckedOutputStream;

import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;

public class ZipCompressor {
static final int BUFFER = 8192;

private File zipFile;

public ZipCompressor(String pathName) {
zipFile = new File(pathName);
}

public void compress(String srcPathName) {
File file = new File(srcPathName);
if (!file.exists())
throw new RuntimeException(srcPathName + "不存在!");
try {
FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream,
new CRC32());
ZipOutputStream out = new ZipOutputStream(cos);
String basedir = "";
compress(file, out, basedir);
out.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

private void compress(File file, ZipOutputStream out, String basedir) {
/* 判断是目录还是文?*/
if (file.isDirectory()) {
System.out.println("压羃Q? + basedir + file.getName());
this.compressDirectory(file, out, basedir);
} else {
System.out.println("压羃Q? + basedir + file.getName());
this.compressFile(file, out, basedir);
}
}

/** 压羃一个目?*/
private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
if (!dir.exists())
return;

File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
/* 递归 */
compress(files[i], out, basedir + dir.getName() + "/");
}
}

/** 压羃一个文?*/
private void compressFile(File file, ZipOutputStream out, String basedir) {
if (!file.exists()) {
return;
}
try {
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(file));
ZipEntry entry = new ZipEntry(basedir + file.getName());
out.putNextEntry(entry);
int count;
byte data[] = new byte[BUFFER];
while ((count = bis.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
bis.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

后来发现原来可以用ant中的org.apache.tools.ant.taskdefs.Zip来实玎ͼ更加单?
Java代码
package net.szh.zip;

import java.io.File;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;

public class ZipCompressorByAnt {

private File zipFile;

public ZipCompressorByAnt(String pathName) {
zipFile = new File(pathName);
}

public void compress(String srcPathName) {
File srcdir = new File(srcPathName);
if (!srcdir.exists())
throw new RuntimeException(srcPathName + "不存在!");

Project prj = new Project();
Zip zip = new Zip();
zip.setProject(prj);
zip.setDestFile(zipFile);
FileSet fileSet = new FileSet();
fileSet.setProject(prj);
fileSet.setDir(srcdir);
//fileSet.setIncludes("**/*.java"); 包括哪些文g或文件夹 eg:zip.setIncludes("*.java");
//fileSet.setExcludes(...); 排除哪些文g或文件夹
zip.addFileset(fileSet);

zip.execute();
}
}

package net.szh.zip;

import java.io.File;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Zip;
import org.apache.tools.ant.types.FileSet;

public class ZipCompressorByAnt {

private File zipFile;

public ZipCompressorByAnt(String pathName) {
zipFile = new File(pathName);
}

public void compress(String srcPathName) {
File srcdir = new File(srcPathName);
if (!srcdir.exists())
throw new RuntimeException(srcPathName + "不存在!");

Project prj = new Project();
Zip zip = new Zip();
zip.setProject(prj);
zip.setDestFile(zipFile);
FileSet fileSet = new FileSet();
fileSet.setProject(prj);
fileSet.setDir(srcdir);
//fileSet.setIncludes("**/*.java"); 包括哪些文g或文件夹 eg:zip.setIncludes("*.java");
//fileSet.setExcludes(...); 排除哪些文g或文件夹
zip.addFileset(fileSet);

zip.execute();
}
}
试一?
Java代码
package net.szh.zip;

public class TestZip {
public static void main(String[] args) {
ZipCompressor zc = new ZipCompressor("E:""szhzip.zip");
zc.compress("E:""test");

ZipCompressorByAnt zca = new ZipCompressorByAnt("E:""szhzipant.zip");
zca.compress("E:""test");
}
}
 




]]>
从URL获取文g保存到本地的JAVA代码Q注Q{载于http://www.builder.com.cn/2007/1116/637608.shtmlQ?/title><link>http://www.aygfsteel.com/anchor110/articles/339903.html</link><dc:creator>一败涂?/dc:creator><author>一败涂?/author><pubDate>Mon, 06 Dec 2010 07:50:00 GMT</pubDate><guid>http://www.aygfsteel.com/anchor110/articles/339903.html</guid><wfw:comment>http://www.aygfsteel.com/anchor110/comments/339903.html</wfw:comment><comments>http://www.aygfsteel.com/anchor110/articles/339903.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/anchor110/comments/commentRss/339903.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/anchor110/services/trackbacks/339903.html</trackback:ping><description><![CDATA[public boolean saveUrlAs(String photoUrl, String fileName) {<br /> //此方法只能用户HTTP协议<br />   try {<br />     URL url = new URL(photoUrl);<br />     HttpURLConnection connection = (HttpURLConnection) url.openConnection();<br />     DataInputStream in = new DataInputStream(connection.getInputStream());<br />     DataOutputStream out = new DataOutputStream(new FileOutputStream(fileName));<br />     byte[] buffer = new byte[4096];<br />     int count = 0;<br />     while ((count = in.read(buffer)) > 0) {<br />     out.write(buffer, 0, count);<br />     }<br />     out.close();<br />     in.close();<br />     return true;<br />   }<br />   catch (Exception e) {<br />     return false;<br />   }<br /> }<br /> <br /> public String getDocumentAt(String urlString) {<br /> //此方法兼容HTTP和FTP协议<br />   StringBuffer document = new StringBuffer();<br />   try {<br />     URL url = new URL(urlString);<br />     URLConnection conn = url.openConnection();<br />     BufferedReader reader = new BufferedReader(new InputStreamReader(conn.<br />       getInputStream()));<br />     String line = null;<br />     while ( (line = reader.readLine()) != null) {<br />     document.append(line + ""n");<br />     }<br />     reader.close();<br />   }<br />   catch (MalformedURLException e) {<br />     System.out.println("Unable to connect to URL: " + urlString);<br />   }<br />   catch (IOException e) {<br />     System.out.println("IOException when connecting to URL: " + urlString);<br />   }<br />   return document.toString();<br /> } <img src ="http://www.aygfsteel.com/anchor110/aggbug/339903.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/anchor110/" target="_blank">一败涂?/a> 2010-12-06 15:50 <a href="http://www.aygfsteel.com/anchor110/articles/339903.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI ***needs 2.1 API. http://www.aygfsteel.com/anchor110/articles/339773.html一败涂?/dc:creator>一败涂?/author>Sat, 04 Dec 2010 02:09:00 GMThttp://www.aygfsteel.com/anchor110/articles/339773.htmlhttp://www.aygfsteel.com/anchor110/comments/339773.htmlhttp://www.aygfsteel.com/anchor110/articles/339773.html#Feedback3http://www.aygfsteel.com/anchor110/comments/commentRss/339773.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/339773.html 解决办法Q?br />     1、如果是application工程Q则在程序中打印?div>         system.out.println(System.getProperty("java.endorsed.dirs"));
         扑ֈ相应位置Q将jaxb-api-2.1.jar和jaxb-impl-2.1.12.jar攑ֈ对应目录下即可。没有endorsed目录Q自己徏一个?br />    2、如果是java web目Q则在一个servlet之类的运行v来的目中,打印Q?div>         system.out.println(System.getProperty("java.endorsed.dirs"));
         扑ֈ相应位置Q将jaxb-api-2.1.jar和jaxb-impl-2.1.12.jar攑ֈ对应目录下即可。没有endorsed目录Q自己徏一个?br />         我的WEB目中,打印出来的\径是QE:\Java\apache-tomcat-7.0.19\endorsed

详情参考这文章:(x)我是参考这文章真正解决问题的?img src ="http://www.aygfsteel.com/anchor110/aggbug/339773.html" width = "1" height = "1" />

]]>
java.lang.UnsupportedClassVersionError: Bad version number in .class filehttp://www.aygfsteel.com/anchor110/articles/339756.html一败涂?/dc:creator>一败涂?/author>Fri, 03 Dec 2010 14:17:00 GMThttp://www.aygfsteel.com/anchor110/articles/339756.htmlhttp://www.aygfsteel.com/anchor110/comments/339756.htmlhttp://www.aygfsteel.com/anchor110/articles/339756.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/339756.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/339756.html
q种q错是由于Tomcatq行的JDK版本与编译application时的JDK版本不一致造成?
把它们的JDK版本Ҏ(gu)一_(d)步骤如下:
1.Window --> Preferences -->Java --> compiler中的compiler compliance level对应的下拉菜单中选择JDK版本.
2.Window --> Preferences -->MyEclipse --> Servers -->Tomcat --> Tomcat n.x -->JDK中的Tomcat JDK name下的下拉菜单中选择自n?sh)脑上安装的JDK版本(必需与步?中的JDK版本一?.




]]>
java中list数据合ƈhttp://www.aygfsteel.com/anchor110/articles/338273.html一败涂?/dc:creator>一败涂?/author>Wed, 17 Nov 2010 08:04:00 GMThttp://www.aygfsteel.com/anchor110/articles/338273.htmlhttp://www.aygfsteel.com/anchor110/comments/338273.htmlhttp://www.aygfsteel.com/anchor110/articles/338273.html#Feedback2http://www.aygfsteel.com/anchor110/comments/commentRss/338273.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/338273.html
list1.addAll(list2);
注:(x)其中list2d到l(f)ist1后面?br />


]]>
JAVA 正则表达?U常用的功能(注:(x)转蝲于http://java.chinaitlab.com/advance/350770.html)http://www.aygfsteel.com/anchor110/articles/330290.html一败涂?/dc:creator>一败涂?/author>Mon, 30 Aug 2010 07:14:00 GMThttp://www.aygfsteel.com/anchor110/articles/330290.htmlhttp://www.aygfsteel.com/anchor110/comments/330290.htmlhttp://www.aygfsteel.com/anchor110/articles/330290.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/330290.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/330290.html
下面单的说下它的4U常用功能:(x)

查询Q?/strong>

    以下是代码片D:(x)
    String str="abc efg ABC";

    String regEx="a|f"; //表示a或f

    Pattern p=Pattern.compile(regEx);

    Matcher m=p.matcher(str);

    boolean rs=m.find();


如果str中有regExQ那么rs为trueQ否则ؓ(f)flase。如果想在查找时忽略大小写,则可以写成Pattern p=Pattern.compile(regEx,Pattern.CASE_INSENSITIVE);

提取Q?/strong>

    以下是代码片D:(x)
    String regEx=".+\\\\(.+)$";

    String str="c:"dir1"dir2"name.txt";

    Pattern p=Pattern.compile(regEx);

    Matcher m=p.matcher(str);

    boolean rs=m.find();

    for(int i=1;i<=m.groupCount();i++){

        System.out.println(m.group(i));

    }


以上的执行结果ؓ(f)name.txtQ提取的字符串储存在m.group(i)中,其中i最大gؓ(f)m.groupCount();

分割Q?br />   
    以下是代码片D:(x)
    String regEx="::";

    Pattern p=Pattern.compile(regEx);

    String[] r=p.split("xd::abc::cde");

    执行后,r是{"xd","abc","cde"}Q其实分割时q有跟简单的Ҏ(gu)Q?

    String str="xd::abc::cde";

    String[] r=str.split("::");


替换Q删除)Q?/strong>

    以下是代码片D:(x)
    String regEx="a+"; //表示一个或多个a

    Pattern p=Pattern.compile(regEx);

    Matcher m=p.matcher("aaabbced a ccdeaa");

    String s=m.replaceAll("A");

l果?Abbced A ccdeA"

如果写成IZQ既可达到删除的功能Q比如:(x)

    String s=m.replaceAll("");

l果?bbced ccde"

附:(x)

  "D {於 [^0-9] 非数?
  "s {於 [ "t"n"x0B"f ] I白字元
  "S {於 [^ "t"n"x0B"f ] 非空白字?
  "w {於 [a-zA-Z_0-9] 数字或是英文?
"W {於 [^a-zA-Z_0-9] 非数字与英文?

^ 表示每行的开?br /> $ 表示每行的结?

]]>
JAVA中的命o(h)调用http://www.aygfsteel.com/anchor110/articles/326612.html一败涂?/dc:creator>一败涂?/author>Tue, 20 Jul 2010 03:03:00 GMThttp://www.aygfsteel.com/anchor110/articles/326612.htmlhttp://www.aygfsteel.com/anchor110/comments/326612.htmlhttp://www.aygfsteel.com/anchor110/articles/326612.html#Feedback0http://www.aygfsteel.com/anchor110/comments/commentRss/326612.htmlhttp://www.aygfsteel.com/anchor110/services/trackbacks/326612.htmlJAVA中启动IEQRuntime.getRuntime().exec("cmd  /c  start  iexplore");

JAVA中打开文本文gQRuntime.getRuntime().exec("cmd  /c  start  d:\\index.txt");


]]>
վ֩ģ壺 | ɽ| ˶| | | ˷| | ˲| ƽ| | ̫| ƽ| Т| | | | ׷| ˻| Ȫ| | | ˮ| | | | »| | Ӷ| ȫ| ̨| | ɽ| ˮ| ɽ| ߴ| ۩| ָ| ϰˮ| ǰ| â| |