﻿<?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-程序人生</title><link>http://www.blogjava.net/caihualin/</link><description>我们站在同一起跑线上,让我们共同努力,共同奋进,愿您的人生因程序而美好!</description><language>zh-cn</language><lastBuildDate>Mon, 21 Sep 2026 07:26:12 GMT</lastBuildDate><pubDate>Mon, 21 Sep 2026 07:26:12 GMT</pubDate><ttl>60</ttl><item><title>linux下mysql的默认字符集修改和默认数据库引擎的修改</title><link>http://www.blogjava.net/caihualin/articles/251900.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Mon, 19 Jan 2009 07:08:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/251900.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/251900.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/251900.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/251900.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/251900.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;
<p class="MsoNormal" style="text-align: left; mso-pagination: widow-orphan" align="left"><strong><span style="font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">关键字<span lang="EN-US">: linux mysql</span></span></strong><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"> <o:p></o:p></span></p>
<p style="text-align: left" align="left"><span style="font-size: 12pt; font-family: 宋体">/etc/init.d/mysql start (stop) </span><span style="font-size: 12pt; font-family: 宋体">为启动和停止服务器 <br />
/etc/mysql/ 主要配置文件所在位置 my.cnf <br />
/var/lib/mysql/ 放置的是数据库表文件夹，这里的mysql相当于windows下mysql的date文件夹 <br />
<br />
启动mysql后，以root登录mysql <br />
isher@isher-ubuntu:~$ mysql -u root <br />
&gt;show variables like 'character%'; #执行编码显示 <br />
+--------------------------+----------------------------+ <br />
| Variable_name | Value | <br />
+--------------------------+----------------------------+ <br />
| character_set_client | latin1 | <br />
| character_set_connection | latin1 | <br />
| character_set_database | latin1 | <br />
| character_set_filesystem | binary | <br />
| character_set_results | latin1 | <br />
| character_set_server | latin1 | <br />
| character_set_system | utf8 | <br />
| character_sets_dir | /usr/share/mysql/charsets/ | <br />
+--------------------------+----------------------------+ <br />
<br />
在某些时候，我们续要修改mysql默认数据库的编码，以保证某些迁移的程序可以正常显示，编辑my.cnf文件进行编码修改,windows可以直接用Ｍysql Server Instance Config Wizard 进行设置 <br />
<br />
在linux下修改３个my.cnf的１个/etc/mysql/my.cnf文件 <br />
<br />
找到客户端配置[client] 在下面添加 <br />
default-character-set=utf8 默认字符集为utf8 <br />
在找到[mysqld] 添加 <br />
default-character-set=utf8 默认字符集为utf8 <br />
init_connect='SET NAMES utf8' （设定连接mysql数据库时使用utf8编码，以让mysql数据库为utf8运行） <br />
<br />
修改好后，重新启动mysql 即可，查询一下show variables like 'character%'; <br />
+--------------------------+----------------------------+ <br />
| Variable_name | Value | <br />
+--------------------------+----------------------------+ <br />
| character_set_client | utf8 | <br />
| character_set_connection | utf8 | <br />
| character_set_database | utf8 | <br />
| character_set_filesystem | binary | <br />
| character_set_results | utf8 | <br />
| character_set_server | utf8 | <br />
| character_set_system | utf8 | <br />
| character_sets_dir | /usr/share/mysql/charsets/ | <br />
+--------------------------+----------------------------+ <br />
<br />
<br />
<br />
此方法用于标准mysql版本同样有效，对于/etc/my.cnf文件，需要从mysql/support-files的文件夹cp my-large.cnf一份到/etc/my.cnf <br />
<br />
<br />
一般安装系统默认是INNODB <br />
default-storage-engine=INNODB <br />
<br />
　　你可以使用很多方法指定一个要使用的存储引擎。最简单的方法是，如果你喜欢一种能满足你的大多数数据库需求的存储引擎，你可以在MySQL设置文件中设置一个默认的引擎类型（使用storage_engine 选项）或者在启动数据库服务器时在命令行后面加上--default-storage-engine或--default-table-type选项。 <br />
<br />
　　更灵活的方式是在随MySQL服务器发布同时提供的MySQL客户端时指定使用的存储引擎。最直接的方式是在创建表时指定存储引擎的类型，向下面这样: <br />
<br />
　　CREATE TABLE mytable (id int, title char(20)) ENGINE = INNODB </span></p>
 <img src ="http://www.blogjava.net/caihualin/aggbug/251900.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2009-01-19 15:08 <a href="http://www.blogjava.net/caihualin/articles/251900.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用appfuse2.0快速搭建环境（myeclipse）（转载）</title><link>http://www.blogjava.net/caihualin/articles/250129.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Tue, 06 Jan 2009 08:23:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/250129.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/250129.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/250129.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/250129.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/250129.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;只有注册用户登录后才能阅读该文。<a href='http://www.blogjava.net/caihualin/articles/250129.html'>阅读全文</a><img src ="http://www.blogjava.net/caihualin/aggbug/250129.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2009-01-06 16:23 <a href="http://www.blogjava.net/caihualin/articles/250129.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AppFuse 2.0 快速起步</title><link>http://www.blogjava.net/caihualin/articles/202416.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 23 May 2008 07:31:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/202416.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/202416.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/202416.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/202416.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/202416.html</trackback:ping><description><![CDATA[<p>&nbsp;</p>
&nbsp;
<p style="text-align: left" align="left"><strong><span style="font-size: 18pt; color: #4e4e4e; font-family: 宋体">AppFuse 2.0 </span></strong><strong><span style="font-size: 18pt; color: #4e4e4e; font-family: 宋体">快速起步</span></strong></p>
<p style="text-align: left" align="left">&nbsp;<span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">英文版网址</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 'Arial','sans-serif'">:<a href="http://appfuse.org/display/APF/AppFuse+QuickStart"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://appfuse.org/display/APF/AppFuse+QuickStart</span></a></span></p>
<p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">请依照以下步骤开始使用AppFuse开发Java EE应用程序：</span></p>
<p style="background: #eeeeee; text-align: left" align="left"><strong><span style="font-size: 12pt; color: #003366; font-family: 宋体">目录</span></strong></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">1.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><a href="http://appfuse.org/display/APF/AppFuse+QuickStart#AppFuseQuickStart-create#AppFuseQuickStart-create"><span style="color: black; text-decoration: none; text-underline: none">建立</span></a></span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">一个新项目. </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">2.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><a href="http://appfuse.org/display/APF/AppFuse+QuickStart#AppFuseQuickStart-run#AppFuseQuickStart-run"><span style="color: black; text-decoration: none; text-underline: none">运行</span></a>. </span></p>
<p style="background: #eeeeee; text-align: left" align="left"><strong><span style="font-size: 12pt; color: #003366; font-family: 宋体">建立项目</span></strong></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">1.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><a href="http://java.sun.com/javase/downloads/"><span style="color: black; text-decoration: none; text-underline: none">下载</span></a></span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">安装JDK 5+. </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">2.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><a href="http://dev.mysql.com/downloads/mysql/5.0.html#downloads"><span style="color: black; text-decoration: none; text-underline: none">下载</span></a></span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">安装MySQL 5.x. </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">3.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">设置一个本地的<a title="Installing an SMTP Server" href="http://appfuse.org/display/APF/Installing+an+SMTP+Server"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">SMTP <span style="color: black; text-decoration: none; text-underline: none">服务器</span></a></span>或者修改</span><span style="font-size: 12pt; color: #4e4e4e; font-family: 宋体">mail.properties</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">文件(位于</span><em><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体; letter-spacing: 0.75pt">src/main/resources</span></em><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">) </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">来使用其它的主机名-默认使用"localhost". </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">4.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><a href="http://maven.apache.org/download.html"><span style="color: black; text-decoration: none; text-underline: none">下载</span></a>&nbsp;<a href="http://maven.apache.org/download.html#Installation"><span style="color: black; text-decoration: none; text-underline: none">安装</span></a>Maven 2.0.8. </span></p>
<div align="center">
<table style="background: #ffffce; margin-left: 36pt; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">如果你更喜欢使用Eclipse 来建立项目，而不是命令行,可以参考<a href="http://candy4appfuse.sourceforge.net/"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">Candy for AppFuse</a>.</span></span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">5</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">、下载appfuse2.0.1并解压appfuse<br />
<a href="https://appfuse.dev.java.net/files/documents/1397/77082/appfuse-dependencies-2.0.1.zip" target="_blank"><span style="color: #4e4e4e; text-decoration: none; text-underline: none">https://appfuse.dev.java.net/files/documents/1397/77082/appfuse-dependencies-2.0.1-with-source-and-javadoc.zip</a><br />
</span>假定解压到D:/appfuse2.0.1/repository下</span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">6</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">、修改%maven_home%/conf/settings.xml<br />
修改settings.xml中的localRepository，指向appfuse的解压目录<br />
&lt;settings&gt;<br />
&nbsp; &lt;!&#8211; localRepository<br />
&nbsp; | The path to the local repository maven will use to store artifacts.<br />
&nbsp; | Default: ~/.m2/repository<br />
&nbsp; &#8211;&gt;<br />
&nbsp; &lt;localRepository&gt;D:/appfuse2.0.1/repository&lt;/localRepository&gt;</span></p>
<p><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><br />
</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">修改原因：默认情况下 repository 在 C:"Documents and Settings"</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">$USER_HOME ".m2"repository </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">，因为这个路径中包含一个空格,所以在后续使用 mvn appfuse:full-source 命令的时候会产生异常； <br />
<br />
</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] Scanning for projects...</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] Searching repository for plugin with prefix: 'appfuse'.</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] ------------------------------------------------------------------------</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] Building AppFuse Modular Application - Core</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO]&nbsp;&nbsp;&nbsp; task-segment: [appfuse:full-source]</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] ------------------------------------------------------------------------</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] ------------------------------------------------------------------------</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[ERROR] FATAL ERROR</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] ------------------------------------------------------------------------</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] null</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Illegal character in path at index 18: file:/C:/Documents and Settings/Administrator/.m2/repository/org/apache/ant/ant/1.7.0/ant-1.7.0.jar</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] ------------------------------------------------------------------------</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">[INFO] Trace</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">java.lang.IllegalArgumentException</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.net.URI.create(URI.java:842)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at java.lang.reflect.Method.invoke(Method.java:597)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.tools.ant.launch.Locator.fromURI(Locator.java:162)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.tools.ant.launch.Locator.getResourceSource(Locator.java:119)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.tools.ant.launch.Locator.getClassSource(Locator.java:90)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.tools.ant.Project.setAntLib(Project.java:313)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at org.apache.tools.ant.Project.initProperties(Project.java:309)</span></p>
<p style="text-align: left; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at org.apache.tools.ant.Project.init(Project.java:295)</span></p>
<p style="text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">官方解决地址http://www.nabble.com/Re%3A-problem-with-appfuse%3Agen-in-windows-p13974654s2369.html <br />
<br />
意思是讲是ant的bug，里面不能有空格，因为Documents and Settings里面有空格所以报错。 </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><br />
</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">另外，由于ant 1.7存在的bug（Problem with appfuse:gen in windows ），因此如果用的是ant 1.7，确认一下$USER_HOME/.m2/repository是否存在，不存在手工创建，并把修改后的settings.xml 拷贝到~".m2"repository下不然在执行后续操作mvn appfuse:full-source时候会报如下错误<br />
java.lang.IllegalArgumentException: When not aligning with a user install you mu<br />
st specify a local repository location using the setLocalRepositoryDirectory( Fi<br />
le ) method.<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.embedder.MavenEmbedder.createMavenSettings(MavenEmbe<br />
dder.java:699)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:628)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In<br />
stallSourceMojo.java:341)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In<br />
stallSourceMojo.java:303)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.appfuse.mojo.installer.InstallSourceMojo.execute(InstallSourceMoj<br />
o.java:142)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi<br />
nManager.java:443)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa<br />
ultLifecycleExecutor.java:539)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone<br />
Goal(DefaultLifecycleExecutor.java:493)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau<br />
ltLifecycleExecutor.java:463)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan<br />
dleFailures(DefaultLifecycleExecutor.java:311)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen<br />
ts(DefaultLifecycleExecutor.java:278)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi<br />
fecycleExecutor.java:143)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.<br />
java:39)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces<br />
sorImpl.java:25)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at java.lang.reflect.Method.invoke(Method.java:585)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; at org.codehaus.classworlds.Launcher.main(Launcher.java:375)<br />
[INFO] ————————————————————————</span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">7</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">．AppFuse拥有很多构造不同风格项目的能力. 为使用户使用起来更优化、更简单, 我们建立了多种原型（又称作：起始项目）. 现在又两种类型的AppFuse 原型:基本的（basic）和模块化的（modular）. 基本原型用于建立基于web应用的项目；模块化原型包含&#8220;核心&#8221;（core）"和"web"模块，用于后台可复用的项目。下表中的命令是用于产生其实项目的，改变</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">groupId</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">就定制包名（package name）；改变</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">artifactId</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">来定制项目名（project's name）. 进入D:"java"workspace,<em>运行如下命令，生成struts2.0的项目<br />
<br />
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=cn.net.xinyi.nvs -DartifactId=nvsweb</em></span></p>
<div align="center">
<table style="background: #ddffdd; margin-left: 36pt; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">在建立原型过程中，是会看到一些警告信息输出。如果在输出信息的末尾看到了&#8220;</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">BUILD SUCCESSFUL</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">&#8221;</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">字样，那就意味着你的项目建立成功了。</span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<table style="margin-left: 36pt; border-collapse: collapse" cellspacing="0" cellpadding="0" border="0">
    <tbody>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: #b2b2b2 1pt dotted; padding-left: 3pt; background: whitesmoke; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: center" align="center"><strong><span style="font-size: 12pt; color: #4e4e4e; font-family: 宋体">Archetype</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: #b2b2b2 1pt dotted; padding-left: 3pt; background: whitesmoke; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: center" align="center"><strong><span style="font-size: 12pt; color: #4e4e4e; font-family: 宋体">Command</span></strong></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">JSF Basic</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-jsf -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Spring MVC Basic</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Struts 2 Basic</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Tapestry Basic</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-tapestry -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">JSF Modular</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-jsf -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Spring MVC Modular</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Struts 2 Modular</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-struts -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Tapestry Modular</span></strong></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-tapestry -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
        <tr>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: #b2b2b2 1pt dotted; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">Core</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"> <br clear="all" />
            (backend only) </span></p>
            </td>
            <td style="border-right: #b2b2b2 1pt dotted; padding-right: 3pt; border-top: medium none; padding-left: 3pt; padding-bottom: 2.25pt; border-left: medium none; padding-top: 2.25pt; border-bottom: #b2b2b2 1pt dotted">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-core -DremoteRepositories=<a href="http://static.appfuse.org/releases"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://static.appfuse.org/releases</span></a>-DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject</span></p>
            </td>
        </tr>
    </tbody>
</table>
<p style="text-indent: -18pt; line-height: 19.2pt; text-align: center" align="center"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">8.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">如果你安装了<a href="http://dev.mysql.com/downloads/mysql/5.0.html#downloads"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">MySQL 5.x</a></span>而且它的root 用户没有设置口令(可以通过update</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">user set password=password('') where user='root'; flush privileges;</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">去掉root的密码)，那你的AppFuse应用就能立即运行起来. 如果你想使用内嵌式的数据库（embedded database）, 我们最近正好增加了一个<a title="Database Profiles" href="http://appfuse.org/display/APF/Database+Profiles"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">Database Profiles</a> </span>文件用于使用H2, HSQLDB等数据库.</span></p>
<div align="center">
<table style="background: #ffffce; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">关于MySQL 安全性</span></strong></p>
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">使用不设置口令的MySQL会导致系统不安全。一旦建立了数据库，可以使用以下命令来设置root用户的口令:<br />
            </span><span style="font-size: 12pt; color: #4e4e4e; font-family: 宋体">mysql --user=root --pass='' mysql -e "update user set password=password('newpw') where user='root'; flush privileges;"</span></p>
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">AppFuse</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">默认使用root用户和空口令，可以编辑项目的pom.xml文件(位于文件末尾)的和 属性，来设置相应的值</span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<p style="background: #eeeeee; text-align: left" align="left"><strong><span style="font-size: 12pt; color: #003366; font-family: 宋体">运行应用程序</span></strong></p>
<p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">现在，运行AppFuse是非常容易得. 一旦建立了原型项目，Maven 就会分别使用<a href="http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">hibernate3</a>and <a href="http://mojo.codehaus.org/dbunit-maven-plugin/"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">dbunit</span></a></span>插件来为你建立并设置数据库.需要你做的只是使用Maven来运行Jetty容器并开始浏览应用了.</span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">1.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">除非你有更好的主意，应该首先把你的项目检入到源码控制服务器中。<a href="http://code.google.com/hosting/"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">Google Code</a></span>提供免费的Subversion 服务, 当然类似的还有很多. </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">2.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">进入命令行， </span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">cd</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">到你的新项目目录，运行</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn integration-test</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">把JARs, Tomcat 和综合测试程序下载到项目里。现在是喝杯咖啡或啤酒和好时机，因为下载和运行测试大约需要5-10分钟. </span></p>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">3.</span><span style="font-size: 7pt; color: #4e4e4e; font-family: 'Times New Roman','serif'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">要浏览应用需在项目目录里运行命令 </span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn jetty:run-war</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"> (</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">对于模块化项目-</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">modular </span></strong><span style="font-size: 9pt; background: #ffffdd; color: #4e4e4e; font-family: 宋体">project, </span><span style="font-size: 9pt; background: #ffffdd; color: #4e4e4e; font-family: 宋体">应在项目的web目录下运行</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn jetty:run-war</span></strong><span style="font-size: 9pt; background: #ffffdd; color: #4e4e4e; font-family: 宋体">命令</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">). Maven </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">将会启动Jetty ，于是就可以在浏览器输入地址<a href="http://localhost:8080/"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">http://localhost:8080/</a></span>来浏览应用了。</span></p>
<div align="center">
<table style="background: #ddffdd; margin-left: 36pt; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">默认的管理用户的用户名和口令是</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">dmin/admin</span></strong><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">，</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">常规用户是</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">user/user</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">。</span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<p style="text-indent: -21pt; line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">4.&nbsp;</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">运行命令 </span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn war:inplace</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">可以覆盖（override）AppFuse的文件.将会只把依赖的WARs文件抽取到</span><em><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体; letter-spacing: 0.75pt">src/main/webapp</span></em><em><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体; letter-spacing: 0.75pt">目录</span></em><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">,</span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">在这里，你可以根据需要改变文件.当你把释放到你的源文件树时，可以运行 </span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn jetty:run</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">命令. 这样一来可以即时修改文件，而Jetty可以根据需要重新装载. 这种方式的唯一的问题是你的项目里的AppFuse将会是不完整("exploded AppFuse"), 会导致更新升级困难.我们推荐在运行命令</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn war:inplace</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">以前，首先将项目检入源码控制系统。这样一来决定哪些文件被保留或删除文件会更容易些. </span></p>
<p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">如果出现内存溢出（OutOfMemory ）错误，请使用</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">jetty:run</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">命令，参照 <a href="http://www.nabble.com/mvn-jetty:run-=%3e-OutOfMemoryError:-PermGen-space-tf3367253s2369.html"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">this mailing list thread</a>. </span></span></p>
<p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">在项目目录里运行命令</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn appfuse:full-source</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">可以将AppFuse的运行模式由内嵌（"embedded mode"）改变为全源码模式（full-source mode）。</span></p>
<div align="center">
<table style="background: #d8e4f1; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">开发环境</span></strong></p>
            <p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">请参照<a title="Development Environment" href="http://appfuse.org/display/APF/Development+Environment"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">development environment</a></span>来了解如何设置你的计算机环境，来开发基于AppFuse的应用开发</span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<div align="center">
<table style="background: #ddffdd; width: 85%" cellspacing="8" cellpadding="0" width="85%" border="0">
    <tbody>
        <tr>
            <td style="padding-right: 3.75pt; padding-left: 3.75pt; background: none transparent scroll repeat 0% 0%; padding-bottom: 3.75pt; padding-top: 3.75pt">
            <p style="line-height: 19.2pt; text-align: left" align="left"><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">改变数据库的设置</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体"><br />
            </span><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">要改变MySQL 数据库的设置，可以简单地修改位于pom.xml末尾的 属性. 参照 <a title="Database Profiles" href="http://appfuse.org/display/APF/Database+Profiles"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">Database Profiles</a> </span>来使用非MySQL的其他数据库.</span></p>
            </td>
        </tr>
    </tbody>
</table>
</div>
<p style="background: #eeeeee; text-align: left" align="left"><strong><span style="font-size: 12pt; color: #003366; font-family: 宋体">应用的部署</span></strong></p>
<p style="line-height: 19.2pt; text-align: left" align="left"><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">可以使用<a title="Eclipse" href="http://appfuse.org/display/APF/Eclipse"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">Eclipse</a>, <a title="IDEA" href="http://appfuse.org/display/APF/IDEA"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">IDEA</span></a> </span>或 <a title="NetBeans" href="http://appfuse.org/display/APF/NetBeans"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">NetBeans</a></span>来部署应用.使用Eclipse,运行 </span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn eclipse:eclipse</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">来生成项目文件. 使用IDEA, 就要使用</span><strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">mvn idea:idea</span></strong><span style="font-size: 9pt; color: #4e4e4e; font-family: 宋体">命令。进一步的介绍请参考<a title="IDEs" href="http://appfuse.org/display/APF/IDEs"><span style="color: black; font-family: 'Trebuchet MS','sans-serif'; text-decoration: none; text-underline: none">IDE Reference Guide</a>.</span></span></p>
<img src ="http://www.blogjava.net/caihualin/aggbug/202416.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-05-23 15:31 <a href="http://www.blogjava.net/caihualin/articles/202416.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>快速排序</title><link>http://www.blogjava.net/caihualin/articles/191120.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Sun, 06 Apr 2008 14:06:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/191120.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/191120.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/191120.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/191120.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/191120.html</trackback:ping><description><![CDATA[<p>package com.eruite.test;</p>
<p>public class QuickSort {<br />
&nbsp;/**<br />
&nbsp; * 快速排序<br />
&nbsp; * <br />
&nbsp; * @param arr<br />
&nbsp; * @param left<br />
&nbsp; * @param right<br />
&nbsp; */<br />
&nbsp;public void quickSort(int[] arr, int left, int right) {<br />
&nbsp;&nbsp;int middle, temp;<br />
&nbsp;&nbsp;int i, j;<br />
&nbsp;&nbsp;i = left;<br />
&nbsp;&nbsp;j = right;<br />
&nbsp;&nbsp;middle = arr[(i + j) / 2];<br />
&nbsp;&nbsp;do {<br />
&nbsp;&nbsp;&nbsp;// 找出左边比中间值大的数<br />
&nbsp;&nbsp;&nbsp;while (arr[i] &lt; middle &amp;&amp; i &lt; right)<br />
&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />
&nbsp;&nbsp;&nbsp;// 找出右边比中间值小的数<br />
&nbsp;&nbsp;&nbsp;while (arr[j] &gt; middle &amp;&amp; j &gt; left)<br />
&nbsp;&nbsp;&nbsp;&nbsp;j--;<br />
&nbsp;&nbsp;&nbsp;// 将左边大的数和右边小的数进行替换<br />
&nbsp;&nbsp;&nbsp;if (i &lt;= j) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;temp = arr[i];<br />
&nbsp;&nbsp;&nbsp;&nbsp;arr[i] = arr[j];<br />
&nbsp;&nbsp;&nbsp;&nbsp;arr[j] = temp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />
&nbsp;&nbsp;&nbsp;&nbsp;j--;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;} while (i &lt;= j); // 当两者交错时停止</p>
<p>&nbsp;&nbsp;if (i &lt; right) {<br />
&nbsp;&nbsp;&nbsp;quickSort(arr, i, right);// 从右边进行递归<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;if (j &gt; left) {<br />
&nbsp;&nbsp;&nbsp;quickSort(arr, left, j);// 从左边进行递归<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * @param args<br />
&nbsp; */<br />
&nbsp;public static void main(String[] args) {<br />
&nbsp;&nbsp;int[] arr = { 11, 66, 22, 0, 55, 22, 0, 32 };<br />
&nbsp;&nbsp;QuickSort sort = new QuickSort();<br />
&nbsp;&nbsp;sort.quickSort(arr, 0, arr.length - 1);<br />
&nbsp;&nbsp;for (int i = 0; i &lt; arr.length; i++) {<br />
&nbsp;&nbsp;&nbsp;System.out.print(arr[i] + " ");<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}<br />
</p>
<img src ="http://www.blogjava.net/caihualin/aggbug/191120.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-04-06 22:06 <a href="http://www.blogjava.net/caihualin/articles/191120.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>金额转换</title><link>http://www.blogjava.net/caihualin/articles/189326.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 28 Mar 2008 10:08:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/189326.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/189326.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/189326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/189326.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/189326.html</trackback:ping><description><![CDATA[<p>package com.eruite.test;</p>
<p>import java.text.NumberFormat;<br />
import java.util.HashMap;</p>
<p>public class SimpleMoneyFormat {<br />
&nbsp;public static final String EMPTY = "";</p>
<p>&nbsp;public static final String ZERO = "零";</p>
<p>&nbsp;public static final String ONE = "壹";</p>
<p>&nbsp;public static final String TWO = "贰";</p>
<p>&nbsp;public static final String THREE = "叁";</p>
<p>&nbsp;public static final String FOUR = "肆";</p>
<p>&nbsp;public static final String FIVE = "伍";</p>
<p>&nbsp;public static final String SIX = "陆";</p>
<p>&nbsp;public static final String SEVEN = "柒";</p>
<p>&nbsp;public static final String EIGHT = "捌";</p>
<p>&nbsp;public static final String NINE = "玖";</p>
<p>&nbsp;public static final String TEN = "拾";</p>
<p>&nbsp;public static final String HUNDRED = "佰";</p>
<p>&nbsp;public static final String THOUSAND = "仟";</p>
<p>&nbsp;public static final String TEN_THOUSAND = "万";</p>
<p>&nbsp;public static final String HUNDRED_MILLION = "亿";</p>
<p>&nbsp;public static final String YUAN = "元";</p>
<p>&nbsp;public static final String JIAO = "角";</p>
<p>&nbsp;public static final String FEN = "分";</p>
<p>&nbsp;public static final String DOT = ".";</p>
<p>&nbsp;private static SimpleMoneyFormat formatter = null;</p>
<p>&nbsp;private HashMap chineseNumberMap = new HashMap();</p>
<p>&nbsp;private HashMap chineseMoneyPattern = new HashMap();</p>
<p>&nbsp;private NumberFormat numberFormat = NumberFormat.getInstance();</p>
<p>&nbsp;private SimpleMoneyFormat() {<br />
&nbsp;&nbsp;numberFormat.setMaximumFractionDigits(4);<br />
&nbsp;&nbsp;numberFormat.setMinimumFractionDigits(2);<br />
&nbsp;&nbsp;numberFormat.setGroupingUsed(false);<br />
&nbsp;&nbsp;chineseNumberMap.put("0", ZERO);<br />
&nbsp;&nbsp;chineseNumberMap.put("1", ONE);<br />
&nbsp;&nbsp;chineseNumberMap.put("2", TWO);<br />
&nbsp;&nbsp;chineseNumberMap.put("3", THREE);<br />
&nbsp;&nbsp;chineseNumberMap.put("4", FOUR);<br />
&nbsp;&nbsp;chineseNumberMap.put("5", FIVE);<br />
&nbsp;&nbsp;chineseNumberMap.put("6", SIX);<br />
&nbsp;&nbsp;chineseNumberMap.put("7", SEVEN);<br />
&nbsp;&nbsp;chineseNumberMap.put("8", EIGHT);<br />
&nbsp;&nbsp;chineseNumberMap.put("9", NINE);<br />
&nbsp;&nbsp;chineseNumberMap.put(DOT, DOT);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("1", TEN);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("2", HUNDRED);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("3", THOUSAND);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("4", TEN_THOUSAND);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("5", TEN);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("6", HUNDRED);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("7", THOUSAND);<br />
&nbsp;&nbsp;chineseMoneyPattern.put("8", HUNDRED_MILLION);<br />
&nbsp;}</p>
<p>&nbsp;public static SimpleMoneyFormat getInstance() {<br />
&nbsp;&nbsp;if (formatter == null)<br />
&nbsp;&nbsp;&nbsp;formatter = new SimpleMoneyFormat();<br />
&nbsp;&nbsp;return formatter;<br />
&nbsp;}</p>
<p>&nbsp;public String format(String moneyStr) {<br />
&nbsp;&nbsp;checkPrecision(moneyStr);<br />
&nbsp;&nbsp;String result = null;<br />
&nbsp;&nbsp;result = convertToChineseNumber(moneyStr);<br />
&nbsp;&nbsp;result = addUnitsToChineseMoneyString(result);<br />
&nbsp;&nbsp;return result;<br />
&nbsp;}</p>
<p>&nbsp;public String format(double moneyDouble) {<br />
&nbsp;&nbsp;return format(numberFormat.format(moneyDouble));<br />
&nbsp;}</p>
<p>&nbsp;public String format(int moneyInt) {<br />
&nbsp;&nbsp;return format(numberFormat.format(moneyInt));<br />
&nbsp;}</p>
<p>&nbsp;public String format(long moneyLong) {<br />
&nbsp;&nbsp;return format(numberFormat.format(moneyLong));<br />
&nbsp;}</p>
<p>&nbsp;public String format(Number moneyNum) {<br />
&nbsp;&nbsp;return format(numberFormat.format(moneyNum));<br />
&nbsp;}</p>
<p>&nbsp;private void checkPrecision(String moneyStr) {<br />
&nbsp;&nbsp;int fractionDigits = moneyStr.length() - moneyStr.indexOf(DOT) - 1;<br />
&nbsp;&nbsp;if (fractionDigits &gt; 2)<br />
&nbsp;&nbsp;&nbsp;throw new RuntimeException("金额" + moneyStr + "的小数位多于两位。"); // 精度不能比分低<br />
&nbsp;}</p>
<p>&nbsp;private String convertToChineseNumber(String moneyStr) {<br />
&nbsp;&nbsp;String result;<br />
&nbsp;&nbsp;StringBuffer cMoneyStringBuffer = new StringBuffer();<br />
&nbsp;&nbsp;for (int i = 0; i &lt; moneyStr.length(); i++) {<br />
&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.append(chineseNumberMap.get(moneyStr.substring(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i, i + 1)));<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;// 拾佰仟万亿等都是汉字里面才有的单位，加上它们<br />
&nbsp;&nbsp;int indexOfDot = cMoneyStringBuffer.indexOf(DOT);<br />
&nbsp;&nbsp;int moneyPatternCursor = 1;<br />
&nbsp;&nbsp;for (int i = indexOfDot - 1; i &gt; 0; i--) {<br />
&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.insert(i, chineseMoneyPattern.get(EMPTY<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ moneyPatternCursor));<br />
&nbsp;&nbsp;&nbsp;moneyPatternCursor = moneyPatternCursor == 8 ? 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: moneyPatternCursor + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;String fractionPart = cMoneyStringBuffer.substring(cMoneyStringBuffer<br />
&nbsp;&nbsp;&nbsp;&nbsp;.indexOf("."));<br />
&nbsp;&nbsp;cMoneyStringBuffer.delete(cMoneyStringBuffer.indexOf("."),<br />
&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.length());</p>
<p>&nbsp;&nbsp;replace(cMoneyStringBuffer, "零拾", ZERO);<br />
&nbsp;&nbsp;replace(cMoneyStringBuffer, "零佰", ZERO);<br />
&nbsp;&nbsp;replace(cMoneyStringBuffer, "零仟", ZERO);<br />
&nbsp;&nbsp;replace(cMoneyStringBuffer, "零万", TEN_THOUSAND);<br />
&nbsp;&nbsp;replace(cMoneyStringBuffer, "零亿", HUNDRED_MILLION);<br />
&nbsp;&nbsp;replace(cMoneyStringBuffer, "零零", ZERO);</p>
<p>&nbsp;&nbsp;if (cMoneyStringBuffer.lastIndexOf(ZERO) == cMoneyStringBuffer.length() - 1)<br />
&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.delete(cMoneyStringBuffer.length() - 1,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.length());<br />
&nbsp;&nbsp;cMoneyStringBuffer.append(fractionPart);<br />
&nbsp;&nbsp;result = cMoneyStringBuffer.toString();<br />
&nbsp;&nbsp;return result;<br />
&nbsp;}</p>
<p>&nbsp;private String addUnitsToChineseMoneyString(String moneyStr) {<br />
&nbsp;&nbsp;String result;<br />
&nbsp;&nbsp;StringBuffer cMoneyStringBuffer = new StringBuffer(moneyStr);<br />
&nbsp;&nbsp;int indexOfDot = cMoneyStringBuffer.indexOf(DOT);<br />
&nbsp;&nbsp;cMoneyStringBuffer.replace(indexOfDot, indexOfDot + 1, YUAN);<br />
&nbsp;&nbsp;cMoneyStringBuffer.insert(cMoneyStringBuffer.length() - 1, JIAO);<br />
&nbsp;&nbsp;cMoneyStringBuffer.insert(cMoneyStringBuffer.length(), FEN);<br />
&nbsp;&nbsp;if (cMoneyStringBuffer.indexOf("零角零分") != -1)// 没有零头，加整<br />
&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零角零分"),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.length(), "整");<br />
&nbsp;&nbsp;else if (cMoneyStringBuffer.indexOf("零分") != -1)// 没有零分，加整<br />
&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零分"),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.length(), "整");<br />
&nbsp;&nbsp;else {<br />
&nbsp;&nbsp;&nbsp;if (cMoneyStringBuffer.indexOf("零角") != -1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.delete(cMoneyStringBuffer.indexOf("零角"),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.indexOf("零角") + 2);<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;result = cMoneyStringBuffer.toString();<br />
&nbsp;&nbsp;return result;<br />
&nbsp;}</p>
<p>&nbsp;private void replace(StringBuffer pValue, String pSource, String pDest) {<br />
&nbsp;&nbsp;if (pValue == null || pSource == null || pDest == null)<br />
&nbsp;&nbsp;&nbsp;return;<br />
&nbsp;&nbsp;/** 记录pSource在pValue中的位置 */<br />
&nbsp;&nbsp;int intPos = 0;<br />
&nbsp;&nbsp;do {<br />
&nbsp;&nbsp;&nbsp;intPos = pValue.toString().indexOf(pSource);<br />
&nbsp;&nbsp;&nbsp;/** 没有找到pSource */<br />
&nbsp;&nbsp;&nbsp;if (intPos == -1)<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;pValue.delete(intPos, intPos + pSource.length());<br />
&nbsp;&nbsp;&nbsp;pValue.insert(intPos, pDest);<br />
&nbsp;&nbsp;} while (true);<br />
&nbsp;}</p>
<p>&nbsp;public static void main(String args[]) {<br />
&nbsp;&nbsp;System.out.println(getInstance().format(new Double(100110010001.01)));<br />
&nbsp;}<br />
}<br />
</p>
<img src ="http://www.blogjava.net/caihualin/aggbug/189326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-03-28 18:08 <a href="http://www.blogjava.net/caihualin/articles/189326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>洗牌功能</title><link>http://www.blogjava.net/caihualin/articles/189325.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 28 Mar 2008 10:01:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/189325.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/189325.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/189325.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/189325.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/189325.html</trackback:ping><description><![CDATA[<p>package com.eruite.test;</p>
<p>import java.util.Random;</p>
<p>public class Poker {<br />
&nbsp;public static void main(String[] args) {<br />
&nbsp;&nbsp;int[] pokers = new int[54];<br />
&nbsp;&nbsp;for (int i = 0; i &lt; pokers.length; i++)<br />
&nbsp;&nbsp;&nbsp;pokers[i] = i;<br />
&nbsp;&nbsp;int j = 0, temp = 0;<br />
&nbsp;&nbsp;for (int i = 0; i &lt; pokers.length; i++) {<br />
&nbsp;&nbsp;&nbsp;Random r = new Random();<br />
&nbsp;&nbsp;&nbsp;j = r.nextInt(54);<br />
&nbsp;&nbsp;&nbsp;temp = pokers[i];<br />
&nbsp;&nbsp;&nbsp;pokers[i] = pokers[j];<br />
&nbsp;&nbsp;&nbsp;pokers[j] = temp;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;for (int i = 0; i &lt; pokers.length; i++) {<br />
&nbsp;&nbsp;&nbsp;System.out.print(pokers[i] + " ");<br />
&nbsp;&nbsp;&nbsp;if ((i + 1) % 10 == 0)<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println();<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}<br />
</p>
<img src ="http://www.blogjava.net/caihualin/aggbug/189325.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-03-28 18:01 <a href="http://www.blogjava.net/caihualin/articles/189325.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>合并法排序</title><link>http://www.blogjava.net/caihualin/articles/189321.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 28 Mar 2008 09:57:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/189321.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/189321.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/189321.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/189321.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/189321.html</trackback:ping><description><![CDATA[  <img src ="http://www.blogjava.net/caihualin/aggbug/189321.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-03-28 17:57 <a href="http://www.blogjava.net/caihualin/articles/189321.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>二叉查找树</title><link>http://www.blogjava.net/caihualin/articles/189319.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 28 Mar 2008 09:55:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/189319.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/189319.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/189319.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/189319.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/189319.html</trackback:ping><description><![CDATA[<p>package com.eruite.test;</p>
<p>class BinaryNode {<br />
&nbsp;Comparable element;</p>
<p>&nbsp;BinaryNode left;</p>
<p>&nbsp;BinaryNode right;</p>
<p>&nbsp;BinaryNode(Comparable element) {<br />
&nbsp;&nbsp;this(element, null, null);<br />
&nbsp;}</p>
<p>&nbsp;BinaryNode(Comparable element, BinaryNode left, BinaryNode right) {<br />
&nbsp;&nbsp;this.element = element;<br />
&nbsp;&nbsp;this.left = left;<br />
&nbsp;&nbsp;this.right = right;<br />
&nbsp;}<br />
}</p>
<p>public class BinarySearchTree {<br />
&nbsp;private BinaryNode root;</p>
<p>&nbsp;public BinarySearchTree() {<br />
&nbsp;&nbsp;root = null;<br />
&nbsp;}</p>
<p>&nbsp;public void makeEmpty() {<br />
&nbsp;&nbsp;root = null;<br />
&nbsp;}</p>
<p>&nbsp;public boolean isEmpty() {<br />
&nbsp;&nbsp;return root == null;<br />
&nbsp;}</p>
<p>&nbsp;public Comparable find(Comparable x) {<br />
&nbsp;&nbsp;return elementAt(find(x, root));<br />
&nbsp;}</p>
<p>&nbsp;public Comparable findMin() {<br />
&nbsp;&nbsp;return elementAt(findMin(root));<br />
&nbsp;}</p>
<p>&nbsp;public Comparable findMax() {<br />
&nbsp;&nbsp;return elementAt(findMax(root));<br />
&nbsp;}</p>
<p>&nbsp;public void insert(Comparable x) {<br />
&nbsp;&nbsp;root = insert(x, root);<br />
&nbsp;}</p>
<p>&nbsp;public void remove(Comparable x) {<br />
&nbsp;&nbsp;root = remove(x, root);<br />
&nbsp;}</p>
<p>&nbsp;public void printTree() {<br />
&nbsp;&nbsp;if (isEmpty())<br />
&nbsp;&nbsp;&nbsp;System.out.println("Empty Tree");<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;printTree(root);<br />
&nbsp;}</p>
<p>&nbsp;private Comparable elementAt(BinaryNode t) {<br />
&nbsp;&nbsp;return t == null ? null : t.element;<br />
&nbsp;}</p>
<p>&nbsp;private BinaryNode find(Comparable x, BinaryNode t) {<br />
&nbsp;&nbsp;if (t == null)<br />
&nbsp;&nbsp;&nbsp;return null;<br />
&nbsp;&nbsp;if (x.compareTo(t.element) &lt; 0)<br />
&nbsp;&nbsp;&nbsp;return find(x, t.left);<br />
&nbsp;&nbsp;else if (x.compareTo(t.element) &gt; 0)<br />
&nbsp;&nbsp;&nbsp;return find(x, t.right);<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;return t;<br />
&nbsp;}</p>
<p>&nbsp;private BinaryNode findMin(BinaryNode t) {<br />
&nbsp;&nbsp;if (t == null)<br />
&nbsp;&nbsp;&nbsp;return null;<br />
&nbsp;&nbsp;else if (t.left == null)<br />
&nbsp;&nbsp;&nbsp;return t;<br />
&nbsp;&nbsp;return findMin(t.left);<br />
&nbsp;}</p>
<p>&nbsp;private BinaryNode findMax(BinaryNode t) {<br />
&nbsp;&nbsp;if (t != null) {<br />
&nbsp;&nbsp;&nbsp;while (t.right != null)<br />
&nbsp;&nbsp;&nbsp;&nbsp;t = t.right;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return t;<br />
&nbsp;}</p>
<p>&nbsp;private BinaryNode insert(Comparable x, BinaryNode t) {<br />
&nbsp;&nbsp;if (t == null)<br />
&nbsp;&nbsp;&nbsp;t = new BinaryNode(x);<br />
&nbsp;&nbsp;else if (x.compareTo(t.element) &lt; 0)<br />
&nbsp;&nbsp;&nbsp;t.left = insert(x, t.left);<br />
&nbsp;&nbsp;else if (x.compareTo(t.element) &gt; 0)<br />
&nbsp;&nbsp;&nbsp;t.right = insert(x, t.right);<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;;<br />
&nbsp;&nbsp;return t;<br />
&nbsp;}</p>
<p>&nbsp;private BinaryNode remove(Comparable x, BinaryNode t) {<br />
&nbsp;&nbsp;if (t == null)<br />
&nbsp;&nbsp;&nbsp;return t;<br />
&nbsp;&nbsp;if (x.compareTo(t.element) &lt; 0)<br />
&nbsp;&nbsp;&nbsp;t.left = remove(x, t.left);<br />
&nbsp;&nbsp;else if (x.compareTo(t.element) &gt; 0)<br />
&nbsp;&nbsp;&nbsp;t.right = remove(x, t.right);<br />
&nbsp;&nbsp;else if (t.left != null &amp;&amp; t.right != null) {<br />
&nbsp;&nbsp;&nbsp;t.element = findMin(t.right).element;<br />
&nbsp;&nbsp;&nbsp;t.right = remove(x, t.right);<br />
&nbsp;&nbsp;} else<br />
&nbsp;&nbsp;&nbsp;t = (t.left != null) ? t.left : t.right;<br />
&nbsp;&nbsp;return t;<br />
&nbsp;}</p>
<p>&nbsp;private void printTree(BinaryNode t) {<br />
&nbsp;&nbsp;if (t != null) {<br />
&nbsp;&nbsp;&nbsp;printTree(t.left);<br />
&nbsp;&nbsp;&nbsp;System.out.print(t.element);<br />
&nbsp;&nbsp;&nbsp;printTree(t.right);<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>&nbsp;public static void main(String[] args) {<br />
&nbsp;&nbsp;BinarySearchTree bst = new BinarySearchTree();<br />
&nbsp;&nbsp;bst.insert(new Integer(1));<br />
&nbsp;&nbsp;bst.insert(new Integer(2));<br />
&nbsp;&nbsp;bst.insert(new Integer(3));<br />
&nbsp;&nbsp;bst.insert(new Integer(4));<br />
&nbsp;&nbsp;bst.insert(new Integer(5));<br />
&nbsp;&nbsp;bst.insert(new Integer(6));<br />
&nbsp;&nbsp;Comparable c = bst.find(new Integer(6));<br />
&nbsp;&nbsp;if (c != null)<br />
&nbsp;&nbsp;&nbsp;System.out.print(c);<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;System.out.println("not exist");<br />
&nbsp;}<br />
}<br />
</p>
 <img src ="http://www.blogjava.net/caihualin/aggbug/189319.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-03-28 17:55 <a href="http://www.blogjava.net/caihualin/articles/189319.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>反转字符串中的单词</title><link>http://www.blogjava.net/caihualin/articles/189314.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Fri, 28 Mar 2008 09:32:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/189314.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/189314.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/189314.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/189314.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/189314.html</trackback:ping><description><![CDATA[<p>package com.eruite.test;</p>
<p>import java.util.StringTokenizer;</p>
<p>public class ReverseWords {<br />
&nbsp;public static String reverseWords(String str) {<br />
&nbsp;&nbsp;if (str == null || str.trim().equals(""))<br />
&nbsp;&nbsp;&nbsp;return null;<br />
&nbsp;&nbsp;StringTokenizer spaceToker = new StringTokenizer(str);<br />
&nbsp;&nbsp;String[] result = new String[spaceToker.countTokens()];<br />
&nbsp;&nbsp;int index = 0;<br />
&nbsp;&nbsp;while (spaceToker.hasMoreTokens()) {<br />
&nbsp;&nbsp;&nbsp;result[index] = spaceToker.nextToken();<br />
&nbsp;&nbsp;&nbsp;index++;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;StringBuffer sb = new StringBuffer();<br />
&nbsp;&nbsp;for (int i = result.length - 1; i &gt;= 0; i--)<br />
&nbsp;&nbsp;&nbsp;sb.append(result[i]+" ");<br />
&nbsp;&nbsp;return sb.toString();<br />
&nbsp;}</p>
<p>&nbsp;public static void main(String[] args) {<br />
&nbsp;&nbsp;String str = "Do or do not, there is no try.";<br />
&nbsp;&nbsp;System.out.print(reverseWords(str));<br />
&nbsp;}<br />
}<br />
</p>
 <img src ="http://www.blogjava.net/caihualin/aggbug/189314.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2008-03-28 17:32 <a href="http://www.blogjava.net/caihualin/articles/189314.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用POI导入和导出Excel文件</title><link>http://www.blogjava.net/caihualin/articles/164724.html</link><dc:creator>蔡华林</dc:creator><author>蔡华林</author><pubDate>Sun, 02 Dec 2007 15:08:00 GMT</pubDate><guid>http://www.blogjava.net/caihualin/articles/164724.html</guid><wfw:comment>http://www.blogjava.net/caihualin/comments/164724.html</wfw:comment><comments>http://www.blogjava.net/caihualin/articles/164724.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/caihualin/comments/commentRss/164724.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/caihualin/services/trackbacks/164724.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;最近做试题导入导出，选用了poi导入和导出excel文件，直接用poi的API感觉代码很混乱，耦合度很高，所以封装了两个底层类。一个是ExcelReader：主要包含读取excel内容的方法；另一个是ExcelWriter：主要包含几个生成excel文件的方法。现贴出来供大家以后参考使用：<br />
<br />
<p>1、ExcelWriter.java<br />
package com.eruite.util;</p>
<p>import java.io.File;<br />
import java.io.FileInputStream;<br />
import java.io.IOException;</p>
<p>import org.apache.poi.hssf.usermodel.HSSFCell;<br />
import org.apache.poi.hssf.usermodel.HSSFRow;<br />
import org.apache.poi.hssf.usermodel.HSSFSheet;<br />
import org.apache.poi.hssf.usermodel.HSSFWorkbook;<br />
import org.apache.poi.poifs.filesystem.POIFSFileSystem;</p>
<p>/**<br />
&nbsp;* @author caihua<br />
&nbsp;*/<br />
public class ExcelReader {<br />
&nbsp;private HSSFWorkbook wb = null;// book [includes sheet]</p>
<p>&nbsp;private HSSFSheet sheet = null;</p>
<p>&nbsp;private HSSFRow row = null;</p>
<p>&nbsp;private int sheetNum = 0; // 第sheetnum个工作表</p>
<p>&nbsp;private int rowNum = 0;</p>
<p>&nbsp;private FileInputStream fis = null;</p>
<p>&nbsp;private File file = null;</p>
<p>&nbsp;public ExcelReader() {<br />
&nbsp;}</p>
<p>&nbsp;public ExcelReader(File file) {<br />
&nbsp;&nbsp;this.file = file;<br />
&nbsp;}</p>
<p>&nbsp;public void setRowNum(int rowNum) {<br />
&nbsp;&nbsp;this.rowNum = rowNum;<br />
&nbsp;}</p>
<p>&nbsp;public void setSheetNum(int sheetNum) {<br />
&nbsp;&nbsp;this.sheetNum = sheetNum;<br />
&nbsp;}</p>
<p>&nbsp;public void setFile(File file) {<br />
&nbsp;&nbsp;this.file = file;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 读取excel文件获得HSSFWorkbook对象<br />
&nbsp; */<br />
&nbsp;public void open() throws IOException {<br />
&nbsp;&nbsp;fis = new FileInputStream(file);<br />
&nbsp;&nbsp;wb = new HSSFWorkbook(new POIFSFileSystem(fis));<br />
&nbsp;&nbsp;fis.close();<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 返回sheet表数目<br />
&nbsp; * <br />
&nbsp; * @return int<br />
&nbsp; */<br />
&nbsp;public int getSheetCount() {<br />
&nbsp;&nbsp;int sheetCount = -1;<br />
&nbsp;&nbsp;sheetCount = wb.getNumberOfSheets();<br />
&nbsp;&nbsp;return sheetCount;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * sheetNum下的记录行数<br />
&nbsp; * <br />
&nbsp; * @return int<br />
&nbsp; */<br />
&nbsp;public int getRowCount() {<br />
&nbsp;&nbsp;if (wb == null)<br />
&nbsp;&nbsp;&nbsp;System.out.println("=============&gt;WorkBook为空");<br />
&nbsp;&nbsp;HSSFSheet sheet = wb.getSheetAt(this.sheetNum);<br />
&nbsp;&nbsp;int rowCount = -1;<br />
&nbsp;&nbsp;rowCount = sheet.getLastRowNum();<br />
&nbsp;&nbsp;return rowCount;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 读取指定sheetNum的rowCount<br />
&nbsp; * <br />
&nbsp; * @param sheetNum<br />
&nbsp; * @return int<br />
&nbsp; */<br />
&nbsp;public int getRowCount(int sheetNum) {<br />
&nbsp;&nbsp;HSSFSheet sheet = wb.getSheetAt(sheetNum);<br />
&nbsp;&nbsp;int rowCount = -1;<br />
&nbsp;&nbsp;rowCount = sheet.getLastRowNum();<br />
&nbsp;&nbsp;return rowCount;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 得到指定行的内容<br />
&nbsp; * <br />
&nbsp; * @param lineNum<br />
&nbsp; * @return String[]<br />
&nbsp; */<br />
&nbsp;public String[] readExcelLine(int lineNum) {<br />
&nbsp;&nbsp;return readExcelLine(this.sheetNum, lineNum);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 指定工作表和行数的内容<br />
&nbsp; * <br />
&nbsp; * @param sheetNum<br />
&nbsp; * @param lineNum<br />
&nbsp; * @return String[]<br />
&nbsp; */<br />
&nbsp;public String[] readExcelLine(int sheetNum, int lineNum) {<br />
&nbsp;&nbsp;if (sheetNum &lt; 0 || lineNum &lt; 0)<br />
&nbsp;&nbsp;&nbsp;return null;<br />
&nbsp;&nbsp;String[] strExcelLine = null;<br />
&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;sheet = wb.getSheetAt(sheetNum);<br />
&nbsp;&nbsp;&nbsp;row = sheet.getRow(lineNum);</p>
<p>&nbsp;&nbsp;&nbsp;int cellCount = row.getLastCellNum();<br />
&nbsp;&nbsp;&nbsp;strExcelLine = new String[cellCount + 1];<br />
&nbsp;&nbsp;&nbsp;for (int i = 0; i &lt;= cellCount; i++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelLine[i] = readStringExcelCell(lineNum, i);<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;} catch (Exception e) {<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return strExcelLine;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 读取指定列的内容<br />
&nbsp; * <br />
&nbsp; * @param cellNum<br />
&nbsp; * @return String<br />
&nbsp; */<br />
&nbsp;public String readStringExcelCell(int cellNum) {<br />
&nbsp;&nbsp;return readStringExcelCell(this.rowNum, cellNum);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 指定行和列编号的内容<br />
&nbsp; * <br />
&nbsp; * @param rowNum<br />
&nbsp; * @param cellNum<br />
&nbsp; * @return String<br />
&nbsp; */<br />
&nbsp;public String readStringExcelCell(int rowNum, int cellNum) {<br />
&nbsp;&nbsp;return readStringExcelCell(this.sheetNum, rowNum, cellNum);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 指定工作表、行、列下的内容<br />
&nbsp; * <br />
&nbsp; * @param sheetNum<br />
&nbsp; * @param rowNum<br />
&nbsp; * @param cellNum<br />
&nbsp; * @return String<br />
&nbsp; */<br />
&nbsp;public String readStringExcelCell(int sheetNum, int rowNum, int cellNum) {<br />
&nbsp;&nbsp;if (sheetNum &lt; 0 || rowNum &lt; 0)<br />
&nbsp;&nbsp;&nbsp;return "";<br />
&nbsp;&nbsp;String strExcelCell = "";<br />
&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;sheet = wb.getSheetAt(sheetNum);<br />
&nbsp;&nbsp;&nbsp;row = sheet.getRow(rowNum);</p>
<p>&nbsp;&nbsp;&nbsp;if (row.getCell((short) cellNum) != null) { // add this condition<br />
&nbsp;&nbsp;&nbsp;&nbsp;// judge<br />
&nbsp;&nbsp;&nbsp;&nbsp;switch (row.getCell((short) cellNum).getCellType()) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_FORMULA:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "FORMULA ";<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_NUMERIC: {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = String.valueOf(row.getCell((short) cellNum)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getNumericCellValue());<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_STRING:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = row.getCell((short) cellNum)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getStringCellValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_BLANK:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;} catch (Exception e) {<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return strExcelCell;<br />
&nbsp;}</p>
<p>&nbsp;public static void main(String args[]) {<br />
&nbsp;&nbsp;File file = new File("C:\\qt.xls");<br />
&nbsp;&nbsp;ExcelReader readExcel = new ExcelReader(file);<br />
&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;readExcel.open();<br />
&nbsp;&nbsp;} catch (IOException e) {<br />
&nbsp;&nbsp;&nbsp;e.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;readExcel.setSheetNum(0); // 设置读取索引为0的工作表<br />
&nbsp;&nbsp;// 总行数<br />
&nbsp;&nbsp;int count = readExcel.getRowCount();<br />
&nbsp;&nbsp;for (int i = 0; i &lt;= count; i++) {<br />
&nbsp;&nbsp;&nbsp;String[] rows = readExcel.readExcelLine(i);<br />
&nbsp;&nbsp;&nbsp;for (int j = 0; j &lt; rows.length; j++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;System.out.print(rows[j] + " ");<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;System.out.print("\n");<br />
&nbsp;&nbsp;}<br />
&nbsp;}<br />
}<br />
<br />
2、ExcelWriter.java<br />
</p>
<p>package com.eruite.util;</p>
<p>import java.io.File;<br />
import java.io.FileNotFoundException;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.OutputStream;<br />
import java.util.Calendar;</p>
<p>import org.apache.poi.hssf.usermodel.HSSFCell;<br />
import org.apache.poi.hssf.usermodel.HSSFCellStyle;<br />
import org.apache.poi.hssf.usermodel.HSSFDataFormat;<br />
import org.apache.poi.hssf.usermodel.HSSFRow;<br />
import org.apache.poi.hssf.usermodel.HSSFSheet;<br />
import org.apache.poi.hssf.usermodel.HSSFWorkbook;</p>
<p>/**<br />
&nbsp;* 生成导出Excel文件对象<br />
&nbsp;* <br />
&nbsp;* @author caihua<br />
&nbsp;* <br />
&nbsp;*/<br />
public class ExcelWriter {<br />
&nbsp;// 设置cell编码解决中文高位字节截断<br />
&nbsp;private static short XLS_ENCODING = HSSFCell.ENCODING_UTF_16;</p>
<p>&nbsp;// 定制浮点数格式<br />
&nbsp;private static String NUMBER_FORMAT = "#,##0.00";</p>
<p>&nbsp;// 定制日期格式<br />
&nbsp;private static String DATE_FORMAT = "m/d/yy"; // "m/d/yy h:mm"</p>
<p>&nbsp;private OutputStream out = null;</p>
<p>&nbsp;private HSSFWorkbook workbook = null;</p>
<p>&nbsp;private HSSFSheet sheet = null;</p>
<p>&nbsp;private HSSFRow row = null;</p>
<p>&nbsp;public ExcelWriter() {<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 初始化Excel<br />
&nbsp; * <br />
&nbsp; */<br />
&nbsp;public ExcelWriter(OutputStream out) {<br />
&nbsp;&nbsp;this.out = out;<br />
&nbsp;&nbsp;this.workbook = new HSSFWorkbook();<br />
&nbsp;&nbsp;this.sheet = workbook.createSheet();<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 导出Excel文件<br />
&nbsp; * <br />
&nbsp; * @throws IOException<br />
&nbsp; */<br />
&nbsp;public void export() throws FileNotFoundException, IOException {<br />
&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;workbook.write(out);<br />
&nbsp;&nbsp;&nbsp;out.flush();<br />
&nbsp;&nbsp;&nbsp;out.close();<br />
&nbsp;&nbsp;} catch (FileNotFoundException e) {<br />
&nbsp;&nbsp;&nbsp;throw new IOException(" 生成导出Excel文件出错! ", e);<br />
&nbsp;&nbsp;} catch (IOException e) {<br />
&nbsp;&nbsp;&nbsp;throw new IOException(" 写入Excel文件出错! ", e);<br />
&nbsp;&nbsp;}</p>
<p>&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 增加一行<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 行号<br />
&nbsp; */<br />
&nbsp;public void createRow(int index) {<br />
&nbsp;&nbsp;this.row = this.sheet.createRow(index);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 获取单元格的值<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列号<br />
&nbsp; */<br />
&nbsp;public String getCell(int index) {<br />
&nbsp;&nbsp;HSSFCell cell = this.row.getCell((short) index);<br />
&nbsp;&nbsp;String strExcelCell = "";<br />
&nbsp;&nbsp;if (cell != null) { // add this condition<br />
&nbsp;&nbsp;&nbsp;// judge<br />
&nbsp;&nbsp;&nbsp;switch (cell.getCellType()) {<br />
&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_FORMULA:<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "FORMULA ";<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_NUMERIC: {<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = String.valueOf(cell.getNumericCellValue());<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_STRING:<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = cell.getStringCellValue();<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;case HSSFCell.CELL_TYPE_BLANK:<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;default:<br />
&nbsp;&nbsp;&nbsp;&nbsp;strExcelCell = "";<br />
&nbsp;&nbsp;&nbsp;&nbsp;break;<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return strExcelCell;<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 设置单元格<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列号<br />
&nbsp; * @param value<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单元格填充值<br />
&nbsp; */<br />
&nbsp;public void setCell(int index, int value) {<br />
&nbsp;&nbsp;HSSFCell cell = this.row.createCell((short) index);<br />
&nbsp;&nbsp;cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);<br />
&nbsp;&nbsp;cell.setCellValue(value);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 设置单元格<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列号<br />
&nbsp; * @param value<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单元格填充值<br />
&nbsp; */<br />
&nbsp;public void setCell(int index, double value) {<br />
&nbsp;&nbsp;HSSFCell cell = this.row.createCell((short) index);<br />
&nbsp;&nbsp;cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);<br />
&nbsp;&nbsp;cell.setCellValue(value);<br />
&nbsp;&nbsp;HSSFCellStyle cellStyle = workbook.createCellStyle(); // 建立新的cell样式<br />
&nbsp;&nbsp;HSSFDataFormat format = workbook.createDataFormat();<br />
&nbsp;&nbsp;cellStyle.setDataFormat(format.getFormat(NUMBER_FORMAT)); // 设置cell样式为定制的浮点数格式<br />
&nbsp;&nbsp;cell.setCellStyle(cellStyle); // 设置该cell浮点数的显示格式<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 设置单元格<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列号<br />
&nbsp; * @param value<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单元格填充值<br />
&nbsp; */<br />
&nbsp;public void setCell(int index, String value) {<br />
&nbsp;&nbsp;HSSFCell cell = this.row.createCell((short) index);<br />
&nbsp;&nbsp;cell.setCellType(HSSFCell.CELL_TYPE_STRING);<br />
&nbsp;&nbsp;cell.setEncoding(XLS_ENCODING);<br />
&nbsp;&nbsp;cell.setCellValue(value);<br />
&nbsp;}</p>
<p>&nbsp;/**<br />
&nbsp; * 设置单元格<br />
&nbsp; * <br />
&nbsp; * @param index<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 列号<br />
&nbsp; * @param value<br />
&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 单元格填充值<br />
&nbsp; */<br />
&nbsp;public void setCell(int index, Calendar value) {<br />
&nbsp;&nbsp;HSSFCell cell = this.row.createCell((short) index);<br />
&nbsp;&nbsp;cell.setEncoding(XLS_ENCODING);<br />
&nbsp;&nbsp;cell.setCellValue(value.getTime());<br />
&nbsp;&nbsp;HSSFCellStyle cellStyle = workbook.createCellStyle(); // 建立新的cell样式<br />
&nbsp;&nbsp;cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat(DATE_FORMAT)); // 设置cell样式为定制的日期格式<br />
&nbsp;&nbsp;cell.setCellStyle(cellStyle); // 设置该cell日期的显示格式<br />
&nbsp;}</p>
<p>&nbsp;public static void main(String[] args) {<br />
&nbsp;&nbsp;System.out.println(" 开始导出Excel文件 ");</p>
<p>&nbsp;&nbsp;File f = new File("C:\\qt.xls");<br />
&nbsp;&nbsp;ExcelWriter e = new ExcelWriter();</p>
<p>&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;e = new ExcelWriter(new FileOutputStream(f));<br />
&nbsp;&nbsp;} catch (FileNotFoundException e1) {<br />
&nbsp;&nbsp;&nbsp;e1.printStackTrace();<br />
&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;e.createRow(0);<br />
&nbsp;&nbsp;e.setCell(0, "试题编码 ");<br />
&nbsp;&nbsp;e.setCell(1, "题型");<br />
&nbsp;&nbsp;e.setCell(2, "分值");<br />
&nbsp;&nbsp;e.setCell(3, "难度");<br />
&nbsp;&nbsp;e.setCell(4, "级别");<br />
&nbsp;&nbsp;e.setCell(5, "知识点");</p>
<p>&nbsp;&nbsp;e.createRow(1);<br />
&nbsp;&nbsp;e.setCell(0, "t1");<br />
&nbsp;&nbsp;e.setCell(1, 1);<br />
&nbsp;&nbsp;e.setCell(2, 3.0);<br />
&nbsp;&nbsp;e.setCell(3, 1);<br />
&nbsp;&nbsp;e.setCell(4, "重要");<br />
&nbsp;&nbsp;e.setCell(5, "专业");</p>
<p>&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;e.export();<br />
&nbsp;&nbsp;&nbsp;System.out.println(" 导出Excel文件[成功] ");<br />
&nbsp;&nbsp;} catch (IOException ex) {<br />
&nbsp;&nbsp;&nbsp;System.out.println(" 导出Excel文件[失败] ");<br />
&nbsp;&nbsp;&nbsp;ex.printStackTrace();<br />
&nbsp;&nbsp;}<br />
&nbsp;}</p>
<p>}</p>
<img src ="http://www.blogjava.net/caihualin/aggbug/164724.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/caihualin/" target="_blank">蔡华林</a> 2007-12-02 23:08 <a href="http://www.blogjava.net/caihualin/articles/164724.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>