<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>一个程序猿 &#187; Java</title>
	<atom:link href="http://www.sunboyu.cn/category/original/java-original/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sunboyu.cn</link>
	<description>时光不会倒流,脚步总要前进</description>
	<lastBuildDate>Tue, 27 Jul 2010 06:24:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用Lucene 构建强大的discuz 论坛搜索模块</title>
		<link>http://www.sunboyu.cn/2010/07/27/discuz_lucene.shtml</link>
		<comments>http://www.sunboyu.cn/2010/07/27/discuz_lucene.shtml#comments</comments>
		<pubDate>Tue, 27 Jul 2010 06:21:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[discuz]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[全文]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=1263</guid>
		<description><![CDATA[在我搞完公司的论坛优化后，我一直想写一个圈套的dz性能优化的方案。当时的全文检索使用的是公司内部某人开发的检索系统，没有开源，所以我做此方案来实现。
此文刚打完草稿，处于调试通过的状态。没有形成具体可用的用户文档。希望在这个底稿的基础上，朋友能给予测试和支持，以鼓励我做出一套完整的方案。
下载：lucene_dz
欢迎加入QQ讨论群：41886598
]]></description>
			<content:encoded><![CDATA[<p>在我搞完公司的论坛优化后，我一直想写一个圈套的dz性能优化的方案。当时的全文检索使用的是公司内部某人开发的检索系统，没有开源，所以我做此方案来实现。<br />
此文刚打完草稿，处于调试通过的状态。没有形成具体可用的用户文档。希望在这个底稿的基础上，朋友能给予测试和支持，以鼓励我做出一套完整的方案。</p>
<p>下载：<a href='http://www.sunboyu.cn/upfiles/2010/07/lucene_dz.pdf'>lucene_dz</a></p>
<p>欢迎加入QQ讨论群：41886598</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2010/07/27/discuz_lucene.shtml/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jar命令的一些应用</title>
		<link>http://www.sunboyu.cn/2008/10/21/jar%e5%91%bd%e4%bb%a4%e7%9a%84%e4%b8%80%e4%ba%9b%e5%ba%94%e7%94%a8.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/21/jar%e5%91%bd%e4%bb%a4%e7%9a%84%e4%b8%80%e4%ba%9b%e5%ba%94%e7%94%a8.shtml#comments</comments>
		<pubDate>Tue, 21 Oct 2008 08:29:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jar]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=358</guid>
		<description><![CDATA[对于我，最常用的两个功能，就是打包类库，创建可执行的JAR。
打包文件，可以看下边的功能呢个表：



功能
命令


用一个单独的文件创建一个 JAR 文件
jar cf jar-file input-file&#8230;


用一个目录创建一个 JAR 文件
jar cf jar-file dir-name


创建一个未压缩的 JAR 文件
jar cf0 jar-file dir-name


更新一个 JAR 文件
jar uf jar-file input-file&#8230;


查看一个 JAR 文件的内容
jar tf jar-file


提取一个 JAR 文件的内容
jar xf jar-file


从一个 JAR 文件中提取特定的文件
jar xf jar-file archived-file&#8230;


运行一个打包为可执行 JAR 文件的应用程序
java -jar app.jar



创建一个可执行 JAR 很容易。首先将所有应用程序代码放到一个目录中。假设应用程序中的主类是 com.mycompany.myapp.Sample 。您要创建一个包含应用程序代码的 JAR 文件并标识出主类。为此，在某个位置(不是在应用程序目录中)创建一个名为  manifest 的文件，并在其中加入以下一行： Main-Class: com.mycompany.myapp.Sample
引用地址:http://www-128.ibm.com/developerworks/cn/java/j-jar/index.html
]]></description>
			<content:encoded><![CDATA[<p>对于我，最常用的两个功能，就是打包类库，创建可执行的JAR。</p>
<p>打包文件，可以看下边的功能呢个表：</p>
<table border="1" cellspacing="0" cellpadding="3" width="80%">
<tbody>
<tr>
<td><strong>功能</strong></td>
<td><strong>命令</strong></td>
</tr>
<tr>
<td>用一个单独的文件创建一个 JAR 文件</td>
<td>jar cf jar-file input-file&#8230;</td>
</tr>
<tr>
<td>用一个目录创建一个 JAR 文件</td>
<td>jar cf jar-file dir-name</td>
</tr>
<tr>
<td>创建一个未压缩的 JAR 文件</td>
<td>jar cf0 jar-file dir-name</td>
</tr>
<tr>
<td>更新一个 JAR 文件</td>
<td>jar uf jar-file input-file&#8230;</td>
</tr>
<tr>
<td>查看一个 JAR 文件的内容</td>
<td>jar tf jar-file</td>
</tr>
<tr>
<td>提取一个 JAR 文件的内容</td>
<td>jar xf jar-file</td>
</tr>
<tr>
<td>从一个 JAR 文件中提取特定的文件</td>
<td>jar xf jar-file archived-file&#8230;</td>
</tr>
<tr>
<td>运行一个打包为可执行 JAR 文件的应用程序</td>
<td>java -jar app.jar</td>
</tr>
</tbody>
</table>
<p>创建一个可执行 JAR 很容易。首先将所有应用程序代码放到一个目录中。假设应用程序中的主类是 com.mycompany.myapp.Sample 。您要创建一个包含应用程序代码的 JAR 文件并标识出主类。为此，在某个位置(不是在应用程序目录中)创建一个名为  manifest 的文件，并在其中加入以下一行： Main-Class: com.mycompany.myapp.Sample</p>
<p>引用地址:http://www-128.ibm.com/developerworks/cn/java/j-jar/index.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/21/jar%e5%91%bd%e4%bb%a4%e7%9a%84%e4%b8%80%e4%ba%9b%e5%ba%94%e7%94%a8.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress使用Lucene进行搜索</title>
		<link>http://www.sunboyu.cn/2008/10/18/wordpress%e4%bd%bf%e7%94%a8lucene%e8%bf%9b%e8%a1%8c%e6%90%9c%e7%b4%a2.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/18/wordpress%e4%bd%bf%e7%94%a8lucene%e8%bf%9b%e8%a1%8c%e6%90%9c%e7%b4%a2.shtml#comments</comments>
		<pubDate>Sat, 18 Oct 2008 05:52:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=354</guid>
		<description><![CDATA[接上篇，我们使用Lucene Document Field IndexWrite 等方法创建了索引，现在，使用内建的搜索的方法进行检索。
代码如下：
import java.io.*;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.analysis.*;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.*;
&#160;
public class Search
{
public static void main( String argv[] ) throws Exception
{
IndexReader reader = IndexReader.open(&#34;./index&#34;);
Searcher searcher = new IndexSearcher(reader);
SimpleAnalyzeranalyzer = new SimpleAnalyzer();
QueryParser parser = new QueryParser(&#34;post_content&#34;, analyzer);
Query query = parser.parse( argv[0] );
Hits hits = searcher.search(query);
System.out.println(hits.length() + &#34;个结果&#34;);
for(int i=0;i
{
System.out.println(hits.doc(i).get(&#34;guid&#34;));
}
}
}
编译后，我们在命令行进行查询：
E:\java>java Search php
40个结果
http://www.sunboyu.cn/?p=332
http://www.sunboyu.cn/?p=164
http://www.sunboyu.cn/?p=213
http://www.sunboyu.cn/?p=123
http://www.sunboyu.cn/?p=124
http://www.sunboyu.cn/?p=180
http://www.sunboyu.cn/?p=283
http://www.sunboyu.cn/?p=282
http://www.sunboyu.cn/?p=234
http://www.sunboyu.cn/?p=53
http://www.sunboyu.cn/?p=159
http://www.sunboyu.cn/?p=235
http://www.sunboyu.cn/?p=221
http://www.sunboyu.cn/?p=73
http://www.sunboyu.cn/?p=11
http://www.sunboyu.cn/?p=51
http://www.sunboyu.cn/?p=240
http://www.sunboyu.cn/?p=196
http://www.sunboyu.cn/?p=52
http://www.sunboyu.cn/?p=308
http://www.sunboyu.cn/?p=298
http://www.sunboyu.cn/?p=9
http://www.sunboyu.cn/?page_id=38
http://www.sunboyu.cn/?p=236
http://www.sunboyu.cn/?p=320
http://www.sunboyu.cn/?p=141
http://www.sunboyu.cn/?p=78
http://www.sunboyu.cn/?p=291
http://www.sunboyu.cn/?p=218
http://www.sunboyu.cn/?p=154
http://www.sunboyu.cn/?p=121
http://www.sunboyu.cn/?p=200
http://www.sunboyu.cn/?p=244
http://www.sunboyu.cn/?p=280
http://www.sunboyu.cn/?page_id=112
http://www.sunboyu.cn/?p=288
http://www.sunboyu.cn/?p=292
http://www.sunboyu.cn/?p=20
http://www.sunboyu.cn/?p=130
http://www.sunboyu.cn/?p=87
E:\java>
可以看到，当我们搜索关键词“php”，返回了所有存在php关键词的链接。
当然，这个只是个简单的演示，在创建索引的时候，我们使用了SimpleAnalyzer的方法，这个方法对中文，其实就是基于单字的分词，对于中文信息检索基本是没有意义的。Lucene提供了开发的源代码，因为，我们可以很方便得为其附加我们自己的中文分词方法。
]]></description>
			<content:encoded><![CDATA[<p>接上篇，我们使用Lucene Document Field IndexWrite 等方法创建了索引，现在，使用内建的搜索的方法进行检索。<br />
代码如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">import java.io.*;</li>
<li>import org.apache.lucene.index.Term;</li>
<li>import org.apache.lucene.index.IndexReader;</li>
<li>import org.apache.lucene.analysis.*;</li>
<li>import org.apache.lucene.queryParser.QueryParser;</li>
<li>import org.apache.lucene.search.*;</li>
<li>&nbsp;</li>
<li>public class Search</li>
<li>{</li>
<li>public static void main( String argv[] ) throws Exception</li>
<li>{</li>
<li>IndexReader reader = IndexReader.open(&quot;./index&quot;);</li>
<li>Searcher searcher = new IndexSearcher(reader);</li>
<li>SimpleAnalyzeranalyzer = new SimpleAnalyzer();</li>
<li>QueryParser parser = new QueryParser(&quot;post_content&quot;, analyzer);</li>
<li>Query query = parser.parse( argv[0] );</li>
<li>Hits hits = searcher.search(query);</li>
<li>System.out.println(hits.length() + &quot;个结果&quot;);</li>
<li>for(int i=0;i</li>
<li>{</li>
<li>System.out.println(hits.doc(i).get(&quot;guid&quot;));</li>
<li>}</li>
<li>}</li>
<li>}</li></ol></div>
<p>编译后，我们在命令行进行查询：</p>
<p>E:\java>java Search php<br />
40个结果<br />
http://www.sunboyu.cn/?p=332<br />
http://www.sunboyu.cn/?p=164<br />
http://www.sunboyu.cn/?p=213<br />
http://www.sunboyu.cn/?p=123<br />
http://www.sunboyu.cn/?p=124<br />
http://www.sunboyu.cn/?p=180<br />
http://www.sunboyu.cn/?p=283<br />
http://www.sunboyu.cn/?p=282<br />
http://www.sunboyu.cn/?p=234<br />
http://www.sunboyu.cn/?p=53<br />
http://www.sunboyu.cn/?p=159<br />
http://www.sunboyu.cn/?p=235<br />
http://www.sunboyu.cn/?p=221<br />
http://www.sunboyu.cn/?p=73<br />
http://www.sunboyu.cn/?p=11<br />
http://www.sunboyu.cn/?p=51<br />
http://www.sunboyu.cn/?p=240<br />
http://www.sunboyu.cn/?p=196<br />
http://www.sunboyu.cn/?p=52<br />
http://www.sunboyu.cn/?p=308<br />
http://www.sunboyu.cn/?p=298<br />
http://www.sunboyu.cn/?p=9<br />
http://www.sunboyu.cn/?page_id=38<br />
http://www.sunboyu.cn/?p=236<br />
http://www.sunboyu.cn/?p=320<br />
http://www.sunboyu.cn/?p=141<br />
http://www.sunboyu.cn/?p=78<br />
http://www.sunboyu.cn/?p=291<br />
http://www.sunboyu.cn/?p=218<br />
http://www.sunboyu.cn/?p=154<br />
http://www.sunboyu.cn/?p=121<br />
http://www.sunboyu.cn/?p=200<br />
http://www.sunboyu.cn/?p=244<br />
http://www.sunboyu.cn/?p=280<br />
http://www.sunboyu.cn/?page_id=112<br />
http://www.sunboyu.cn/?p=288<br />
http://www.sunboyu.cn/?p=292<br />
http://www.sunboyu.cn/?p=20<br />
http://www.sunboyu.cn/?p=130<br />
http://www.sunboyu.cn/?p=87</p>
<p>E:\java><br />
可以看到，当我们搜索关键词“php”，返回了所有存在php关键词的链接。</p>
<p>当然，这个只是个简单的演示，在创建索引的时候，我们使用了SimpleAnalyzer的方法，这个方法对中文，其实就是基于单字的分词，对于中文信息检索基本是没有意义的。Lucene提供了开发的源代码，因为，我们可以很方便得为其附加我们自己的中文分词方法。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/18/wordpress%e4%bd%bf%e7%94%a8lucene%e8%bf%9b%e8%a1%8c%e6%90%9c%e7%b4%a2.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用Lucene为WordPress创建索引</title>
		<link>http://www.sunboyu.cn/2008/10/15/%e4%bd%bf%e7%94%a8lucene%e4%b8%bawordpress%e5%88%9b%e5%bb%ba%e7%b4%a2%e5%bc%95.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/15/%e4%bd%bf%e7%94%a8lucene%e4%b8%bawordpress%e5%88%9b%e5%bb%ba%e7%b4%a2%e5%bc%95.shtml#comments</comments>
		<pubDate>Wed, 15 Oct 2008 07:41:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[lucence]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=346</guid>
		<description><![CDATA[上次说到Lucene的Document模型，现在，我们使用WordPress为例，为其创建索引。
分析wordpress数据库结构，我们只需要为标题内容，即主要的文本内容创建索引即可。
具体语句为:  SELECT ID,post_title,post_content,guid FROM wp_posts ORDER BY ID DESC
如下代码，mysql连接类用的上文的mysql类，代码风格还是很PHP。生成的索引全保存在当前的index文件夹下
E:\java\index 的目录
2008-10-16  14:40
.
2008-10-16  14:40              ..
2008-10-16  14:40                20 segments.gen
2008-10-16  14:40       [...]]]></description>
			<content:encoded><![CDATA[<p>上次说到Lucene的Document模型，现在，我们使用WordPress为例，为其创建索引。</p>
<p>分析wordpress数据库结构，我们只需要为标题内容，即主要的文本内容创建索引即可。</p>
<p>具体语句为:  SELECT ID,post_title,post_content,guid FROM wp_posts ORDER BY ID DESC</p>
<p>如下代码，mysql连接类用的上文的mysql类，代码风格还是很PHP。生成的索引全保存在当前的index文件夹下</p>
<p>E:\java\index 的目录</p>
<p>2008-10-16  14:40</p>
<p>.<br />
2008-10-16  14:40              ..<br />
2008-10-16  14:40                20 segments.gen<br />
2008-10-16  14:40                98 segments_a4<br />
2008-10-16  14:40           268,174 _a0.fdt<br />
2008-10-16  14:40             2,600 _a0.fdx<br />
2008-10-16  14:40                37 _a0.fnm<br />
2008-10-16  14:40            20,990 _a0.frq<br />
2008-10-16  14:40             1,304 _a0.nrm<br />
2008-10-16  14:40            27,210 _a0.prx<br />
2008-10-16  14:40             1,281 _a0.tii<br />
2008-10-16  14:40           130,051 _a0.tis<br />
2008-10-16  14:40               356 _a1.fdt<br />
<span id="more-346"></span><br />
2008-10-16  14:40                 8 _a1.fdx<br />
2008-10-16  14:40                37 _a1.fnm<br />
2008-10-16  14:40                23 _a1.frq<br />
2008-10-16  14:40                 8 _a1.nrm<br />
2008-10-16  14:40                23 _a1.prx<br />
2008-10-16  14:40                35 _a1.tii<br />
2008-10-16  14:40               413 _a1.tis<br />
2008-10-16  14:40             1,362 _a2.fdt<br />
2008-10-16  14:40                 8 _a2.fdx<br />
2008-10-16  14:40                37 _a2.fnm<br />
2008-10-16  14:40                74 _a2.frq<br />
2008-10-16  14:40                 8 _a2.nrm<br />
2008-10-16  14:40                87 _a2.prx<br />
2008-10-16  14:40                35 _a2.tii<br />
2008-10-16  14:40             1,348 _a2.tis<br />
26 个文件        455,627 字节<br />
2 个目录 30,843,887,616 可用字节</p>
<p>E:\java\index</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">import java.io.*;</li>
<li>import org.apache.lucene.document.Document;</li>
<li>import org.apache.lucene.document.Field;</li>
<li>import org.apache.lucene.index.IndexWriter;</li>
<li>import org.apache.lucene.analysis.SimpleAnalyzer;</li>
<li>import org.apache.lucene.analysis.Analyzer;</li>
<li>public class Index</li>
<li>{</li>
<li>private MysqlConn Db = null;</li>
<li>//构造函数</li>
<li>public void Index()</li>
<li>{</li>
<li>}</li>
<li>//建立mysql连接</li>
<li>public void getConn( String conndsn )</li>
<li>{</li>
<li>this.Db = new MysqlConn();</li>
<li>this.Db.SetDsn( conndsn );</li>
<li>}</li>
<li>public static void main( String args[] )</li>
<li>{</li>
<li>Index index = new Index();</li>
<li>index.getConn( &quot;jdbc:mysql://localhost:3306/wp&quot; );</li>
<li>index.Db.SetUserPass( &quot;root&quot; , &quot;123456&quot; );</li>
<li>index.Db.Conn();</li>
<li>String sql = &quot;SELECT ID,post_title,post_content,guid FROM wp_posts ORDER BY ID DESC&quot;;</li>
<li>index.Db.sqlQuery( sql );</li>
<li>try</li>
<li>{</li>
<li>while( index.Db.rs.next() )</li>
<li>{</li>
<li>String ID = index.Db.rs.getString( &quot;ID&quot; );</li>
<li>String post_title = index.Db.rs.getString( &quot;post_title&quot; );</li>
<li>String post_content = index.Db.rs.getString( &quot;post_content&quot; );</li>
<li>String guid = index.Db.rs.getString( &quot;guid&quot; );</li>
<li>Document doc = new Document();</li>
<li>//注释1</li>
<li>Field f1 = new Field(&quot;ID&quot;,ID,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>Field f2 = new Field(&quot;post_title&quot;,post_title,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>Field f3 = new Field(&quot;post_content&quot;,post_content,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>Field f4 = new Field(&quot;guid&quot;,guid,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>doc.add( f1 );</li>
<li>doc.add( f2 );</li>
<li>doc.add( f3 );</li>
<li>doc.add( f4 );</li>
<li>System.out.println( ID );</li>
<li>try</li>
<li>{</li>
<li>IndexWriter writer = new IndexWriter( &quot;./index&quot; , new SimpleAnalyzer() );</li>
<li>writer.setUseCompoundFile(false);</li>
<li>writer.addDocument( doc );</li>
<li>writer.close();</li>
<li>}</li>
<li>catch (Exception e)</li>
<li>{</li>
<li>System.out.println(&quot;Error : &quot; + e.toString());</li>
<li>}</li>
<li>}</li>
<li>}</li>
<li>catch(Exception e)</li>
<li>{</li>
<li>System.out.println(&quot;Error : &quot; + e.toString());</li>
<li>}</li>
<li>&nbsp;</li>
<li>}</li>
<li>}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/15/%e4%bd%bf%e7%94%a8lucene%e4%b8%bawordpress%e5%88%9b%e5%bb%ba%e7%b4%a2%e5%bc%95.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lucene创建Document代码部分-循序渐进学Lucene</title>
		<link>http://www.sunboyu.cn/2008/10/08/lucene%e5%88%9b%e5%bb%badocument%e4%bb%a3%e7%a0%81%e9%83%a8%e5%88%86-%e5%be%aa%e5%ba%8f%e6%b8%90%e8%bf%9b%e5%ad%a6lucene.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/08/lucene%e5%88%9b%e5%bb%badocument%e4%bb%a3%e7%a0%81%e9%83%a8%e5%88%86-%e5%be%aa%e5%ba%8f%e6%b8%90%e8%bf%9b%e5%ad%a6lucene.shtml#comments</comments>
		<pubDate>Wed, 08 Oct 2008 10:47:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[lucene]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=337</guid>
		<description><![CDATA[import java.io.*;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.analysis.SimpleAnalyzer;
public class Index
{
	public static void main( String args[] )
	{
		Document doc = new Document();
		//注释1
		Field f1 = new Field(&#34;name1&#34;,&#34;value1&#34;,Field.Store.YES,Field.Index.TOKENIZED);
		Field f2 = new Field(&#34;name2&#34;,&#34;value2&#34;,Field.Store.YES,Field.Index.TOKENIZED);
		doc.add( f1 );
		doc.add( f2 );
		try
		{
			IndexWriter writer = new IndexWriter( &#34;./&#34; , new SimpleAnalyzer() , true );
			writer.addDocument( doc );
			writer.close();
		}
		catch (Exception e)
		{
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">import java.io.*;</li>
<li>import org.apache.lucene.document.Document;</li>
<li>import org.apache.lucene.document.Field;</li>
<li>import org.apache.lucene.index.IndexWriter;</li>
<li>import org.apache.lucene.analysis.SimpleAnalyzer;</li>
<li>public class Index</li>
<li>{</li>
<li>	public static void main( String args[] )</li>
<li>	{</li>
<li>		Document doc = new Document();</li>
<li>		//注释1</li>
<li>		Field f1 = new Field(&quot;name1&quot;,&quot;value1&quot;,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>		Field f2 = new Field(&quot;name2&quot;,&quot;value2&quot;,Field.Store.YES,Field.Index.TOKENIZED);</li>
<li>		doc.add( f1 );</li>
<li>		doc.add( f2 );</li>
<li>		try</li>
<li>		{</li>
<li>			IndexWriter writer = new IndexWriter( &quot;./&quot; , new SimpleAnalyzer() , true );</li>
<li>			writer.addDocument( doc );</li>
<li>			writer.close();</li>
<li>		}</li>
<li>		catch (Exception e)</li>
<li>		{</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace(); </li>
<li>		}</li>
<li>	}</li>
<li>}</li></ol></div>
<p>注释1：Field方法的在2.0.0版本中有5种方法，在2.3.2中增加到了7种，详细用法请参阅官方文档<br />
http://lucene.apache.org/java/2_0_0/api/org/apache/lucene/document/Field.html<br />
http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/document/Field.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/08/lucene%e5%88%9b%e5%bb%badocument%e4%bb%a3%e7%a0%81%e9%83%a8%e5%88%86-%e5%be%aa%e5%ba%8f%e6%b8%90%e8%bf%9b%e5%ad%a6lucene.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lucene文档模型(Document)简解</title>
		<link>http://www.sunboyu.cn/2008/10/04/lucene%e6%96%87%e6%a1%a3%e6%a8%a1%e5%9e%8bdocument%e7%ae%80%e8%a7%a3.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/04/lucene%e6%96%87%e6%a1%a3%e6%a8%a1%e5%9e%8bdocument%e7%ae%80%e8%a7%a3.shtml#comments</comments>
		<pubDate>Sat, 04 Oct 2008 03:39:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[简介]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=334</guid>
		<description><![CDATA[最近仔细研究了Lucene的文档模式，现用通俗语言来解释。
Lucene的索引，基本结构为 Index-&#62;Document-&#62;Field 这样可以构建一个非关系型二维结构，由不同field构成的一个Document，由不同的Document构成的Index。
Lucene的Field方法很丰富，在2.0版本以后，由三种Field类型增加到了5种，支持三种数据流的传入方式（字符串，读取，二进制传入），支持数据的存储，索引，分词。
而我们使用Lucene的主要功能在于分词和生成索引。具体应用待详细使用后介绍。
]]></description>
			<content:encoded><![CDATA[<p>最近仔细研究了Lucene的文档模式，现用通俗语言来解释。</p>
<p>Lucene的索引，基本结构为 Index-&gt;Document-&gt;Field 这样可以构建一个非关系型二维结构，由不同field构成的一个Document，由不同的Document构成的Index。</p>
<p>Lucene的Field方法很丰富，在2.0版本以后，由三种Field类型增加到了5种，支持三种数据流的传入方式（字符串，读取，二进制传入），支持数据的存储，索引，分词。</p>
<p>而我们使用Lucene的主要功能在于分词和生成索引。具体应用待详细使用后介绍。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/04/lucene%e6%96%87%e6%a1%a3%e6%a8%a1%e5%9e%8bdocument%e7%ae%80%e8%a7%a3.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>我的一个Java程序</title>
		<link>http://www.sunboyu.cn/2008/10/03/%e6%88%91%e7%9a%84%e4%b8%80%e4%b8%aajava%e7%a8%8b%e5%ba%8f.shtml</link>
		<comments>http://www.sunboyu.cn/2008/10/03/%e6%88%91%e7%9a%84%e4%b8%80%e4%b8%aajava%e7%a8%8b%e5%ba%8f.shtml#comments</comments>
		<pubDate>Fri, 03 Oct 2008 09:42:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql连接]]></category>

		<guid isPermaLink="false">http://www.sunboyu.cn/?p=333</guid>
		<description><![CDATA[PHP总有其局限性，比如解释型语言在速度上的弱点，制约了它在效率方面的发挥。facebook开放了源代码，其底层大都是c来编写，而我现在计划用Java为一些服务写后台，这是我的第一个Java程序，希望大家多批评，虽然上边依然有太多php的影子。
import java.sql.*;
/*
&#160;*&#160; Java Mysql数据库连接类
&#160;*&#160; 我的第一个java程序
&#160;*/
public class MysqlConn
{
	private String dsn = &#34;jdbc:mysql://localhost:3306/test&#34;;
	private String username = &#34;root&#34;;
	private String password = &#34;123456&#34;;
&#160;
	private Connection conn = null;
	private Statement stmt = null;
	private ResultSet rs = null;
&#160;
&#160;
&#160;
&#160;
&#160;&#160; &#160;public void MysqlConn()
	{
	}
&#160;&#160; &#160;//初始化连接参数
	public void SetDsn( String Dsn )
	{
		this.dsn = Dsn;
	}
	//初始化用户名密码
	public void SetUserPass( String Username , String Password )
	{
		this.username = Username;
		this.password = Password;
	}
	//连接函数
	public void [...]]]></description>
			<content:encoded><![CDATA[<p>PHP总有其局限性，比如解释型语言在速度上的弱点，制约了它在效率方面的发挥。facebook开放了源代码，其底层大都是c来编写，而我现在计划用Java为一些服务写后台，这是我的第一个Java程序，希望大家多批评，虽然上边依然有太多php的影子。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">import java.sql.*;</li>
<li>/*</li>
<li>&nbsp;*&nbsp; Java Mysql数据库连接类</li>
<li>&nbsp;*&nbsp; 我的第一个java程序</li>
<li>&nbsp;*/</li>
<li>public class MysqlConn</li>
<li>{</li>
<li>	private String dsn = &quot;jdbc:mysql://localhost:3306/test&quot;;</li>
<li>	private String username = &quot;root&quot;;</li>
<li>	private String password = &quot;123456&quot;;</li>
<li>&nbsp;</li>
<li>	private Connection conn = null;</li>
<li>	private Statement stmt = null;</li>
<li>	private ResultSet rs = null;</li>
<li>&nbsp;</li>
<li>&nbsp;</li>
<li>&nbsp;</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp;public void MysqlConn()</li>
<li>	{</li>
<li>	}</li>
<li>&nbsp;&nbsp; &nbsp;//初始化连接参数</li>
<li>	public void SetDsn( String Dsn )</li>
<li>	{</li>
<li>		this.dsn = Dsn;</li>
<li>	}</li>
<li>	//初始化用户名密码</li>
<li>	public void SetUserPass( String Username , String Password )</li>
<li>	{</li>
<li>		this.username = Username;</li>
<li>		this.password = Password;</li>
<li>	}</li>
<li>	//连接函数</li>
<li>	public void Conn()</li>
<li>	{</li>
<li>		try</li>
<li>		{</li>
<li>			//加载Connetc/J驱动</li>
<li>			//Class.forName(&quot;com.mysql.jdbc.Driver&quot;);</li>
<li>			Class.forName(&quot;org.gjt.mm.mysql.Driver&quot;);</li>
<li>			//开始连接</li>
<li>			this.conn = DriverManager.getConnection( this.dsn , this.username , this.password );</li>
<li>			this.stmt = this.conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE , ResultSet.CONCUR_UPDATABLE );</li>
<li>		}</li>
<li>		catch(SQLException ex)</li>
<li>		{</li>
<li>			System.out.println(&quot;Error : &quot; + ex.toString());</li>
<li>			System.out.println(&quot;没有找到JDBC/ODBC驱动程序！&quot;);</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>		catch(Exception e)</li>
<li>		{</li>
<li>			System.out.println(&quot;Errors: &quot; + e.toString());</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>		</li>
<li>	}</li>
<li>&nbsp;&nbsp; &nbsp;//返回结果集</li>
<li>	public ResultSet sqlQuery( String sql )</li>
<li>	{</li>
<li>		try</li>
<li>		{</li>
<li>			this.rs = this.stmt.executeQuery( sql );</li>
<li>		}</li>
<li>		catch (SQLException ex)</li>
<li>		{</li>
<li>			System.out.println(&quot;Error : &quot; + ex.toString());</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>		catch (Exception ex)</li>
<li>		{</li>
<li>			System.out.println(&quot;Error : &quot; + ex.toString());</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>		return rs;</li>
<li>	}</li>
<li>	//执行 update,insert之类</li>
<li>	public void Exec( String sql )</li>
<li>	{</li>
<li>		try</li>
<li>		{</li>
<li>			this.stmt.executeUpdate( sql )</li>
<li>		}</li>
<li>		catch (SQLException ex)</li>
<li>		{</li>
<li>			System.out.println(&quot;Error : &quot; + ex.toString());</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>		catch (Exception ex)</li>
<li>		{</li>
<li>			System.out.println(&quot;Error : &quot; + ex.toString());</li>
<li>			System.exit(0);</li>
<li>		}</li>
<li>	}</li>
<li>&nbsp;</li>
<li>}</li></ol></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sunboyu.cn/2008/10/03/%e6%88%91%e7%9a%84%e4%b8%80%e4%b8%aajava%e7%a8%8b%e5%ba%8f.shtml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.647 seconds -->
