﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-wonderer's program</title><link>http://www.blogjava.net/wonderer/</link><description>everything will be better</description><language>zh-cn</language><lastBuildDate>Thu, 30 Apr 2026 06:25:02 GMT</lastBuildDate><pubDate>Thu, 30 Apr 2026 06:25:02 GMT</pubDate><ttl>60</ttl><item><title>《Java学习笔记》--对象容器之ArrayList和LinkedList</title><link>http://www.blogjava.net/wonderer/archive/2007/12/27/171019.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Thu, 27 Dec 2007 15:05:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/12/27/171019.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/171019.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/12/27/171019.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/171019.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/171019.html</trackback:ping><description><![CDATA[<p>去SA面试的时候，面试官问我平时用Java的什么数据结构，答曰：Vector。又问：哪有用过其他的的吗？例如List和Map之类的。答曰：甚少。（自己汗一个，没水平）既然不会就要学习啦。</p> <p>翻开《Java学习笔记》，里面对对象容器的描述不错。</p> <p>1. ArrayList和LinkedList</p> <p>ArrayList使用了数组结构实现List的数据。所以ArraryList用来快速定位对象是非常有效率的。但是如果要对ArraryList中间插入或者删除，效率会非常低。</p> <p>LinkedList使用链表来实现的List。所以跟ArrayList相反，LinkedList对于插入和删除是非常有优势，反之对于快速定位，是LinkedList的弱项。</p> <p>1)ArrayListDemo</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> ArrayListDemo {
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> main(String[] args) {
        
        <span style="color: #008000">//用Scanner类，可以轻松获得commander的输入</span>
        Scanner scanner = <span style="color: #0000ff">new</span> Scanner(System.<span style="color: #0000ff">in</span>);
        
        List&lt;String&gt; list = <span style="color: #0000ff">new</span> ArrayList&lt;String&gt;();
        
        <span style="color: #008000">//在控制台输入，quit退出</span>
        <span style="color: #0000ff">while</span>(<span style="color: #0000ff">true</span>) {
            System.<span style="color: #0000ff">out</span>.print(<span style="color: #006080">"Rokey@console# "</span>);
            String input = scanner.next();
            <span style="color: #0000ff">if</span>(input.equals(<span style="color: #006080">"quit"</span>)) {
                <span style="color: #0000ff">break</span>;
            }
            list.add(input);
        }
        
        System.<span style="color: #0000ff">out</span>.print(<span style="color: #006080">"显示输入："</span>);
        
        <span style="color: #008000">//使用5.0的foreach功能对List进行遍历</span>
        <span style="color: #0000ff">for</span>(String s:list) {
            <span style="color: #008000">//5.0的类C的输出格式</span>
            System.<span style="color: #0000ff">out</span>.printf(<span style="color: #006080">"%s "</span>,s);
        }
    }
}</pre></div>
<p>输出：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">Rokey@console# 一二三
Rokey@console# 三二一
Rokey@console# quit
显示输入：一二三 三二一 
</pre></div>
<p>&nbsp;</p>
<p>2)用LinkedList实现的一个字符串栈</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">/**</span>
<span style="color: #008000"> *</span>
<span style="color: #008000"> * @author Rokey</span>
<span style="color: #008000"> * 用LinkedList构建一个字符栈，先进先出</span>
<span style="color: #008000"> */</span>
<span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> StringStack {

    <span style="color: #0000ff">private</span> LinkedList&lt;String&gt; linkList;

    <span style="color: #0000ff">public</span> StringStack() {
        linkList = <span style="color: #0000ff">new</span> LinkedList&lt;String&gt;();
    }

    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> push(String s) {
        <span style="color: #008000">//将元素加入链表第一个位置</span>
        linkList.addFirst(s);
    }

    <span style="color: #0000ff">public</span> String pop() {
        <span style="color: #008000">//删除链表第一个元素，并返回</span>
        <span style="color: #0000ff">return</span> linkList.removeFirst();
    }

    <span style="color: #0000ff">public</span> String top() {
        <span style="color: #008000">//返回链表第一个元素，但并不删除</span>
        <span style="color: #0000ff">return</span> linkList.getFirst();
    }

    <span style="color: #0000ff">public</span> boolean isEmpty() {
        <span style="color: #008000">//检查链表是否为空</span>
        <span style="color: #0000ff">return</span> linkList.isEmpty();
    }
}</pre></div>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> StringStackDemo {

    <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> main(String[] args) {

        <span style="color: #008000">//用Scanner类，可以轻松获得commander的输入</span>
        Scanner scanner = <span style="color: #0000ff">new</span> Scanner(System.<span style="color: #0000ff">in</span>);

        StringStack stack = <span style="color: #0000ff">new</span> StringStack();

        <span style="color: #008000">//在控制台输入，quit退出</span>
        <span style="color: #0000ff">while</span> (<span style="color: #0000ff">true</span>) {
            System.<span style="color: #0000ff">out</span>.print(<span style="color: #006080">"Rokey@console# "</span>);
            String input = scanner.next();
            <span style="color: #0000ff">if</span> (input.equals(<span style="color: #006080">"quit"</span>)) {
                <span style="color: #0000ff">break</span>;
            }
            stack.push(input);
        }

        System.<span style="color: #0000ff">out</span>.print(<span style="color: #006080">"显示输入："</span>);
        <span style="color: #008000">//使用5.0的foreach功能对List进行遍历</span>
        
        <span style="color: #0000ff">while</span>(!stack.isEmpty()) {
            <span style="color: #008000">//5.0的类C的输出格式</span>
            System.<span style="color: #0000ff">out</span>.printf(<span style="color: #006080">"%s "</span>, stack.pop());
        }
    }
}</pre></div>
<p>输出：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">Rokey@console# 一二三
Rokey@console# 三二一
Rokey@console# quit
显示输入：三二一 一二三 </pre></div><img src ="http://www.blogjava.net/wonderer/aggbug/171019.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-12-27 23:05 <a href="http://www.blogjava.net/wonderer/archive/2007/12/27/171019.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java中的全角和半角</title><link>http://www.blogjava.net/wonderer/archive/2007/12/23/169811.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Sun, 23 Dec 2007 08:46:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/12/23/169811.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/169811.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/12/23/169811.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/169811.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/169811.html</trackback:ping><description><![CDATA[OYM中的任务中，有一项对文件内容的检查挺有意思的，就是要检查字符是否是全角的，例如&#8220;ＧＹ&#8221;（not&#8220;GY&#8221;），并且把这些字符改为半角的。<br />
想起了在研发中心的一个朋友的抱怨：&#8220;昨天写了一整天的程序，发到广大教务处那边居然说不能用，然后亲自跑了一躺，发现不是我的程序有问题，是那边的人输入个全角字符，搜半角的字符，当然不行了&#8221;<br />
恩，Betty写的需求真有意思，考虑的问题很周全，是一个很厉害的项目经理。如果从输入这里解决了字符是否是半角的，那么，以后的情况就容易解决很多了。恩，网上搜了一下资料，查了一下书，得出了以下代码：<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #0000ff;">public</span><span style="color: #000000;">&nbsp;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&nbsp;testChar()&nbsp;{<br />
&nbsp;&nbsp;String&nbsp;s1&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">123</span><span style="color: #000000;">"</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;String&nbsp;s2&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">ａｂｃ</span><span style="color: #000000;">"</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;String&nbsp;s3&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">"</span><span style="color: #000000;">123ａｂｃ</span><span style="color: #000000;">"</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;System.out.println(s1);<br />
&nbsp;&nbsp;System.out.println(s2);<br />
&nbsp;&nbsp;System.out.println(s3);<br />
&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;s1.length();&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;s1.charAt(i);<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(j&nbsp;</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">256</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;temp&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">65248</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(temp&nbsp;</span><span style="color: #000000;">&gt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)j</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">--&gt;:</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;temp);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;System.out.println();<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;s2.length();&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;s2.charAt(i);<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(j&nbsp;</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">256</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;temp&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">65248</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(temp&nbsp;</span><span style="color: #000000;">&gt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)j</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">--&gt;:</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;temp);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.print&nbsp;((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;System.out.println();<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;</span><span style="color: #0000ff;">for</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;i&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">;&nbsp;i&nbsp;</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">&nbsp;s3.length();&nbsp;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;s3.charAt(i);<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(j&nbsp;</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">256</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">int</span><span style="color: #000000;">&nbsp;temp&nbsp;</span><span style="color: #000000;">=</span><span style="color: #000000;">&nbsp;j&nbsp;</span><span style="color: #000000;">-</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">65248</span><span style="color: #000000;">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff;">if</span><span style="color: #000000;">&nbsp;(temp&nbsp;</span><span style="color: #000000;">&gt;=</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">0</span><span style="color: #000000;">)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)j</span><span style="color: #000000;">+</span><span style="color: #000000;">"</span><span style="color: #000000;">--&gt;:</span><span style="color: #000000;">"</span><span style="color: #000000;">&nbsp;</span><span style="color: #000000;">+</span><span style="color: #000000;">&nbsp;(</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;temp);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}&nbsp;</span><span style="color: #0000ff;">else</span><span style="color: #000000;">&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.print((</span><span style="color: #0000ff;">char</span><span style="color: #000000;">)&nbsp;j);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;System.out.println();<br />
&nbsp;<br />
&nbsp;}</span></div>
输出的结果如下：<br />
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;">123</span><span style="color: #000000;"><br />
ａ</span><span style="color: #000000;">--&gt;</span><span style="color: #000000;">aｂ</span><span style="color: #000000;">--&gt;</span><span style="color: #000000;">bｃ</span><span style="color: #000000;">--</span><span style="color: #000000;">c<br />
123ａ</span><span style="color: #000000;">--&gt;</span><span style="color: #000000;">aｂ</span><span style="color: #000000;">--&gt;</span><span style="color: #000000;">bｃ</span><span style="color: #000000;">--</span><span style="color: #000000;">c</span></div>
<br />
<br />
<img src ="http://www.blogjava.net/wonderer/aggbug/169811.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-12-23 16:46 <a href="http://www.blogjava.net/wonderer/archive/2007/12/23/169811.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JEE上传文件的IO流</title><link>http://www.blogjava.net/wonderer/archive/2007/12/23/169676.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Sat, 22 Dec 2007 16:52:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/12/23/169676.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/169676.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/12/23/169676.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/169676.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/169676.html</trackback:ping><description><![CDATA[<p>OYM的任务中，有个要求，上传一个Excel文件，检查他的内容是否合法，并返回信息。</p> <p>今天想了一下，第一个要解决的问题就是上传一个Excel文件，上传文件的组件到挺多的，网上一搜，就有一大堆教程，但是现在并不是要上传一个文件到服务器以作存储之用，而是要上传一个文件到内存里，以Java的数据结构存储起来，并检查，把合乎要求的数据写到数据库里。所以在网上的一大堆上传文件的组件并不合用。于是又想自己写，思路就是从客户端那里获取一个InputStream，然后就对这个InputStream做一系列的检查。代码如下：</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">ServletInputStream sis =  request.getInputStream();
InputStreamReader isr = <span style="color: #0000ff">new</span> InputStreamReader(sis);
             
<span style="color: #0000ff">int</span> ch;
<span style="color: #0000ff">while</span>((ch = isr.read()) != -1 ) {          
   <span style="color: #0000ff">out</span>.println((<span style="color: #0000ff">char</span>)ch);
}
             
System.<span style="color: #0000ff">out</span>.flush();</pre></div>
<p>结果的出去就是如下（输出东西写到页面）：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">-----------------------------7d7ea23120550 
Content-Disposition: form-data; name=<span style="color: #006080">"file1"</span>; 
filename=<span style="color: #006080">"C:\Documents and Settings\Administrator\桌面\test.txt"</span> 
Content-Type: text/plain 
my name <span style="color: #0000ff">is</span> Rokey.Ｒｏｋｅｙ。我的名字叫Rokey. 
-----------------------------7d7ea23120550 Content-Disposition: form-data; 
name=<span style="color: #006080">"Submit"</span> 上传 -----------------------------7d7ea23120550--</pre></div>很明显，这里只有
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">my name <span style="color: #0000ff">is</span> Rokey.Ｒｏｋｅｙ。我的名字叫Rokey.</pre></div>
<p>对我有用，这个也正是我的文件里面的内容，其它的都是关于这些form的其它信息。对我这个程序是没有用的。如果这里写下去的话，还要我去分析那些是数据，哪些是form的参数。好，到现在为止，我已经打消了自己写的念头了。我想，那些组件都可以把上传文件封装得那么好，能不能利用那些库，抽出文件的IO流，让我操作呢?</p>
<p>于是，就开始对<a href="http://www.servlets.com/cos/">O'Reilly的上传组件cos.jar</a>的API看，看到里面有这么一段。</p>
<blockquote>
<p>public class MultipartParser<br>extends java.lang.Object<br>A utility class to handle multipart/form-data requests, the kind of requests that support file uploads. This class uses a "pull" model where the reading of incoming files and parameters is controlled by the client code, which allows incoming files to be stored into any OutputStream. If you wish to use an API which resembles HttpServletRequest, use the "push" model MultipartRequest instead. It's an easy-to-use wrapper around this class. 
<p>This class can receive arbitrarily large files (up to an artificial limit you can set), and fairly efficiently too. It cannot handle nested data (multipart content within multipart content). It can now with the latest release handle internationalized content (such as non Latin-1 filenames). 
<p>It also optionally includes enhanced buffering and Content-Length limitation. Buffering is only required if your servlet container is poorly implemented (many are, including Tomcat 3.2), but it is generally recommended because it will make a slow servlet container a lot faster, and will only make a fast servlet container a little slower. Content-Length limiting is usually only required if you find that your servlet is hanging trying to read the input stram from the POST, and it is similarly recommended because it only has a minimal impact on performance. </p></blockquote>
<p>而且里面的API已经封装程我想象得到的情况了。于是，我就觉得这样我就可以完成我的功能了。于是，就写了以下代码：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">MultipartParser mp = <span style="color: #0000ff">new</span> MultipartParser(request, 10 * 1024 * 1024);
Part part;
<span style="color: #0000ff">while</span> ((part = mp.readNextPart()) != <span style="color: #0000ff">null</span>) {
      <span style="color: #0000ff">if</span> (part.isParam()) {
          <span style="color: #008000">// it's a parameter part</span>
          ParamPart paramPart = (ParamPart) part;
          <span style="color: #008000">//out.println("param: name=" + name + "; value=" + value);</span>
      } <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (part.isFile()) {
          FilePart filePart = (FilePart) part;
          InputStream <span style="color: #0000ff">is</span> = filePart.getInputStream();
          InputStreamReader isr = <span style="color: #0000ff">new</span> InputStreamReader(<span style="color: #0000ff">is</span>);

          <span style="color: #0000ff">int</span> ch;
          <span style="color: #0000ff">while</span> ((ch = isr.read()) != -1) {

              <span style="color: #0000ff">out</span>.print((<span style="color: #0000ff">char</span>) ch);
          }

          System.<span style="color: #0000ff">out</span>.flush();
          isr.close();
          <span style="color: #0000ff">is</span>.close();
      }
}
               </pre></div>
<p>出去结果如下：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">my name <span style="color: #0000ff">is</span> Rokey.Ｒｏｋｅｙ。
我的名字叫Rokey.</pre></div>到现在，已经可以把这个流封装成一个文件流，送给Excel的组件去处理了。<img src ="http://www.blogjava.net/wonderer/aggbug/169676.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-12-23 00:52 <a href="http://www.blogjava.net/wonderer/archive/2007/12/23/169676.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转：什么是IOC</title><link>http://www.blogjava.net/wonderer/archive/2007/10/28/156488.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Sun, 28 Oct 2007 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/10/28/156488.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/156488.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/10/28/156488.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/156488.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/156488.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 什么是IOC呢，在网上搜到了一非常有意思的讲解。IoC就是Inversion of Control，控制反转。在Java开发中，IoC意味着将你设计好的类交给系统去控制，而不是在你的类内部控制。这称为控制反转。 下面我们以几个例子来说明什么是IoC 假设我们要设计一个Girl和一个Boy类，其中Girl有kiss方法，即Girl想要Kiss一个Boy。那么，我们的问题是，Girl如何能够认识这个B...&nbsp;&nbsp;<a href='http://www.blogjava.net/wonderer/archive/2007/10/28/156488.html'>阅读全文</a><img src ="http://www.blogjava.net/wonderer/aggbug/156488.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-10-28 16:50 <a href="http://www.blogjava.net/wonderer/archive/2007/10/28/156488.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Buffola的编码问题</title><link>http://www.blogjava.net/wonderer/archive/2007/10/26/156188.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Fri, 26 Oct 2007 08:41:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/10/26/156188.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/156188.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/10/26/156188.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/156188.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/156188.html</trackback:ping><description><![CDATA[<p>Buffloa里的传递参数的编码是GBK。</p> <p>buffalo.switchPart('body',url,false);如果url中包含汉字，是采用GBK编码的。在不改变tomcat的配置文件的情况下，在目标页面里获得url参数的正确方法是 </p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> String name = <span style="color: #0000ff">new</span> String(request.getParameter(<span style="color: #006080">"name"</span>).getBytes(</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>             <span style="color: #006080">"ISO8859-1"</span>), <span style="color: #006080">"GBK"</span>);</pre></div></div>
<p>注意，如果这里用utf-8作为编码的转换的话，会出现乱码。</p><img src ="http://www.blogjava.net/wonderer/aggbug/156188.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-10-26 16:41 <a href="http://www.blogjava.net/wonderer/archive/2007/10/26/156188.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JSP中request.getParameter()乱码问题</title><link>http://www.blogjava.net/wonderer/archive/2007/10/25/155980.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Thu, 25 Oct 2007 15:23:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/10/25/155980.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/155980.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/10/25/155980.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/155980.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/155980.html</trackback:ping><description><![CDATA[<p>最近在准备考试系统的开发，碰到了 request.getParameter乱码的问题。跟林彬讨论了一下，还是觉得用老方法管用。</p> <p>如果是post的话，可以通过设置filter的方法来解决。</p> <p>如果是get或者是超链接的话，以前是通过设置tomcat的配置文件server.xml来解决的，但这样不好，并不是所有的项目，我们都可以修改到服务器的tomcat的配置文件。具体代码如下：</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> Connector port=<span style="color: #006080">"8080"</span> maxHttpHeaderSize=<span style="color: #006080">"8192"</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>                maxThreads=<span style="color: #006080">"150"</span> minSpareThreads=<span style="color: #006080">"25"</span> maxSpareThreads=<span style="color: #006080">"75"</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>                enableLookups=<span style="color: #006080">"false"</span> redirectPort=<span style="color: #006080">"8443"</span> acceptCount=<span style="color: #006080">"100"</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>                connectionTimeout=<span style="color: #006080">"20000"</span> disableUploadTimeout=<span style="color: #006080">"true"</span> uRIEncoding=<span style="color: #006080">"gbk"</span>/&gt;</pre></div></div>
<p>还是觉得老方法管用，只是有点麻烦:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> String id=<span style="color: #0000ff">new</span> String(request.getParameter(<span style="color: #006080">"id"</span>).getBytes(<span style="color: #006080">"ISO8859-1"</span>),<span style="color: #006080">"UTF-8"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> String name = <span style="color: #0000ff">new</span> String(request.getParameter(<span style="color: #006080">"name"</span>).getBytes(<span style="color: #006080">"ISO8859-1"</span>),<span style="color: #006080">"UTF-8"</span>);</pre></div></div><img src ="http://www.blogjava.net/wonderer/aggbug/155980.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-10-25 23:23 <a href="http://www.blogjava.net/wonderer/archive/2007/10/25/155980.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>设置ip的bat</title><link>http://www.blogjava.net/wonderer/archive/2007/09/11/144317.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Tue, 11 Sep 2007 09:25:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/09/11/144317.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/144317.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/09/11/144317.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/144317.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/144317.html</trackback:ping><description><![CDATA[<p>电脑搬回了宿舍，破解了校园网，多人公用一条宽带。要一个主机拨号。ip总不免要设来设去，总是要手工改，很麻烦，于是上网查了查，写了个改ip的bat文件。内容如下：</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 109px; background-color: #f4f4f4"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><p><span style="color: #606060">   1:</span> netsh <span style="color: #0000ff">interface</span> ip <span style="color: #0000ff">set</span> address name=<span style="color: #006080">"本地连接"</span> source=<span style="color: #0000ff">static</span> addr=192.168.0.39</p><p>            mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1</p></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> netsh <span style="color: #0000ff">interface</span> ip <span style="color: #0000ff">set</span> dns name = <span style="color: #006080">"本地连接"</span> source = <span style="color: #0000ff">static</span> addr = 202.116.128.1</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> netsh <span style="color: #0000ff">interface</span> ip add dns name = <span style="color: #006080">"本地连接"</span> addr = 202.116.128.2</pre></div></div><img src ="http://www.blogjava.net/wonderer/aggbug/144317.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-09-11 17:25 <a href="http://www.blogjava.net/wonderer/archive/2007/09/11/144317.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>html中TD标签的一个小问题</title><link>http://www.blogjava.net/wonderer/archive/2007/08/03/134177.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Fri, 03 Aug 2007 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/08/03/134177.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/134177.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/08/03/134177.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/134177.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/134177.html</trackback:ping><description><![CDATA[<p>在写HTML中，并不是&amp;nbsp才会产生一个空格。&lt;td&gt;hello&nbsp;(间隔一个空格)&lt;/td&gt;输出的数据是： hello+一个空格.如果是对这数据进行修改然后再写回到数据库的话，这样就会产生错误。</p> <p>如下写法是会错误的，</p> <p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="45" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_thumb.png" width="283" border="0"></a> </p> <p>造成的结果是 <a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_1.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="37" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_thumb_1.png" width="120" border="0"></a>&nbsp; 仔细留意会发现运通后面多了一个空格</p> <p>必须改成一下写法：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_2.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="35" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_thumb_2.png" width="279" border="0"></a>&nbsp;</p> <p>注意&lt;/td&gt;跟前面是没有空格的。这样运行结果就会是这样的<a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_3.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="53" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/htmlTD_92F0/image_thumb_3.png" width="100" border="0"></a> ，是没有空格的。</p><img src ="http://www.blogjava.net/wonderer/aggbug/134177.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-08-03 10:32 <a href="http://www.blogjava.net/wonderer/archive/2007/08/03/134177.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring DAO入门</title><link>http://www.blogjava.net/wonderer/archive/2007/07/18/131058.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Wed, 18 Jul 2007 06:04:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/07/18/131058.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/131058.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/07/18/131058.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/131058.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/131058.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 写了个Spring的DAO入门例子。 DAO的接口     1: package dataSourceDemo;   2: &nbsp;   3: public interface IUserDAO {   4:     public void insert(User user);   5:     public User find(Integer id);   6: &nbsp;   7: }...&nbsp;&nbsp;<a href='http://www.blogjava.net/wonderer/archive/2007/07/18/131058.html'>阅读全文</a><img src ="http://www.blogjava.net/wonderer/aggbug/131058.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-07-18 14:04 <a href="http://www.blogjava.net/wonderer/archive/2007/07/18/131058.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JUnit+Spring入门</title><link>http://www.blogjava.net/wonderer/archive/2007/07/18/130992.html</link><dc:creator>wonderer</dc:creator><author>wonderer</author><pubDate>Wed, 18 Jul 2007 03:12:00 GMT</pubDate><guid>http://www.blogjava.net/wonderer/archive/2007/07/18/130992.html</guid><wfw:comment>http://www.blogjava.net/wonderer/comments/130992.html</wfw:comment><comments>http://www.blogjava.net/wonderer/archive/2007/07/18/130992.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/wonderer/comments/commentRss/130992.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/wonderer/services/trackbacks/130992.html</trackback:ping><description><![CDATA[<p>首先要导入包</p> <p>1：Spring支持包：spring.jar , commons-logging.jar</p> <p>2: JUnit支持包： JUnit.jar</p> <p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="131" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_thumb.png" width="239" border="0"></a> </p> <p>建立Bean类，</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> package refBeanDemo;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> import java.util.Date;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> HelloBean {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">private</span> String helloWorld;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">private</span> Date date;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     <span style="color: #0000ff">public</span> Date getDate() {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">return</span> date;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> setDate(Date date) {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #0000ff">this</span>.date = date;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     <span style="color: #0000ff">public</span> String getHelloWorld() {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #0000ff">return</span> helloWorld;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> setHelloWorld(String helloWorld) {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #0000ff">this</span>.helloWorld = helloWorld;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span> }</pre></div></div>
<p>&nbsp;</p>
<p>建立配置文件，和在里面进行注入</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">="1.0"</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">="UTF-8"</span>?<span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #0000ff">&lt;!</span><span style="color: #800000">DOCTYPE</span> <span style="color: #ff0000">beans</span> <span style="color: #ff0000">PUBLIC</span> <span style="color: #0000ff">"-//SPRING/DTD BEAN/EN"</span> <span style="color: #0000ff">"../resources/spring-beans-2.0.dtd"</span> <span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">beans</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">bean</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">="dateBean"</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="java.util.Date"</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">bean</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">bean</span> <span style="color: #ff0000">id</span><span style="color: #0000ff">="helloBean"</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">="refBeanDemo.HelloBean"</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="helloWorld"</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>             <span style="color: #0000ff">&lt;</span><span style="color: #800000">value</span><span style="color: #0000ff">&gt;</span>你好，世界<span style="color: #0000ff">&lt;/</span><span style="color: #800000">value</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">&lt;/</span><span style="color: #800000">property</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         <span style="color: #0000ff">&lt;</span><span style="color: #800000">property</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="date"</span> <span style="color: #ff0000">ref</span><span style="color: #0000ff">="dateBean"</span><span style="color: #0000ff">&gt;&lt;/</span><span style="color: #800000">property</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">&lt;/</span><span style="color: #800000">bean</span><span style="color: #0000ff">&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">beans</span><span style="color: #0000ff">&gt;</span></pre></div></div>
<p>写JUnit进行测试，方便管理，把JUnit的东东放到test包里。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> package refBeanDemo;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> import org.springframework.context.ApplicationContext;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> import org.springframework.context.support.ClassPathXmlApplicationContext;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> import junit.framework.TestCase;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> TestRefBeanDemo extends TestCase {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #0000ff">private</span> ApplicationContext context;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> setUp() {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         context = <span style="color: #0000ff">new</span> ClassPathXmlApplicationContext(<span style="color: #006080">"refBeanDemo/NewFile.xml"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> testSpring() {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         HelloBean helloBean = (HelloBean)context.getBean(<span style="color: #006080">"helloBean"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         System.<span style="color: #0000ff">out</span>.println(helloBean.getDate());</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         assertEquals(<span style="color: #006080">"你好，世界"</span>, helloBean.getHelloWorld());</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span> }</pre></div></div>
<p>&nbsp;</p>
<p>运行JUnit测试</p>
<p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_1.png" atomicselection="true"></a><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_2.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="142" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_thumb_2.png" width="487" border="0"></a> </p>
<p>测试成功。类的分布如下：</p>
<p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_3.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="84" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_thumb_3.png" width="223" border="0"></a> </p>
<p><a href="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_4.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" alt="image" src="http://www.blogjava.net/images/blogjava_net/wonderer/WindowsLiveWriter/JUnitSpring_9CE8/image_thumb_4.png" border="0"></a></p><img src ="http://www.blogjava.net/wonderer/aggbug/130992.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/wonderer/" target="_blank">wonderer</a> 2007-07-18 11:12 <a href="http://www.blogjava.net/wonderer/archive/2007/07/18/130992.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>