<?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>MoDoFo.println(" &#187; 代码</title>
	<atom:link href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81/feed" rel="self" type="application/rss+xml" />
	<link>http://zhangv.com</link>
	<description>Life for Idea - forever young</description>
	<lastBuildDate>Sat, 07 Apr 2012 04:08:37 +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>面向对象和充血/贫血模型</title>
		<link>http://zhangv.com/archives/1743</link>
		<comments>http://zhangv.com/archives/1743#comments</comments>
		<pubDate>Wed, 26 Oct 2011 06:05:07 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[面向对象]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://zhangv.com/archives/1743</guid>
		<description><![CDATA[面向对象和是否使用充血模型，是两个概念，不存在冲突。
如果使用充血模型，你的代码读起来就好像：今天他来了，然后他死了。 - he.goto(Place,TrafficTool); he.died(DeadReason);
而贫血模型的话，读起来就像是：一辆大巴载着他来了，然后死神带走了他。 - bus.taketo(He,Place); death.takeaway(He);
&#8220;他&#8221;就是模型，在整个编程模型中怎么理解他至关重要，否则在开发团队里就存在混用的情况。用哪种模型完全取决于个人喜好。
一般充血模型比较适合逻辑不是很复杂，比如大多数都是单表，不存在复杂的关联的情况。贫血模型的使用范围比较广，用着也简单，但代码看起来多，而且读起来吞吞吐吐。毕竟充血模型需要在扩展时非常清楚合理地把行为定义到正确的模型上。

	Tags: 面向对象, 代码
]]></description>
			<content:encoded><![CDATA[<p>面向对象和是否使用充血模型，是两个概念，不存在冲突。</p>
<p>如果使用充血模型，你的代码读起来就好像：今天他来了，然后他死了。 - he.goto(Place,TrafficTool); he.died(DeadReason);</p>
<p>而贫血模型的话，读起来就像是：一辆大巴载着他来了，然后死神带走了他。 - bus.taketo(He,Place); death.takeaway(He);</p>
<p>&ldquo;他&rdquo;就是模型，在整个编程模型中怎么理解他至关重要，否则在开发团队里就存在混用的情况。用哪种模型完全取决于个人喜好。</p>
<p>一般充血模型比较适合逻辑不是很复杂，比如大多数都是单表，不存在复杂的关联的情况。贫血模型的使用范围比较广，用着也简单，但代码看起来多，而且读起来吞吞吐吐。毕竟充血模型需要在扩展时非常清楚合理地把行为定义到正确的模型上。</p>

	Tags: <a href="http://zhangv.com/archives/tag/%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1" title="面向对象" rel="tag">面向对象</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/1743/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Discuz如何让帖子列表的标题显示帖子附件中的图片</title>
		<link>http://zhangv.com/archives/1106</link>
		<comments>http://zhangv.com/archives/1106#comments</comments>
		<pubDate>Wed, 24 Jun 2009 02:26:46 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[discuz]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://zhangv.com/archives/1106</guid>
		<description><![CDATA[Discuz的代码还是比较容易看懂的。关键是要找到需要改的地方。第1步：forumdisplay.php，用来准备要显示的帖子列表，然后用forumdisplay.htm作为显示模板。找到forumdisplay.php中的：$query = $sdb-&#62;query("SELECT t.* FROM {$tablepre}threads t&#160;&#160;&#160; &#160;&#160;&#160; WHERE t.fid='$fid' $filteradd AND $displayorderadd&#160;&#160;&#160; &#160;&#160;&#160; ORDER BY t.displayorder DESC, t.$orderby $ascdesc&#160;&#160;&#160; &#160;&#160;&#160; LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");
替换为：$query = $sdb-&#62;query("SELECT t.*,min(att.attachment) as attm FROM {$tablepre}threads t&#160;&#160;&#160; &#160;&#160;&#160; LEFT JOIN {$tablepre}posts p ON p.tid=t.tid&#160;&#160;&#160; &#160;&#160;&#160; LEFT JOIN {$tablepre}attachments att ON att.tid=t.tid&#160;&#160;&#160; &#160;&#160;&#160; WHERE t.fid='$fid' [...]]]></description>
			<content:encoded><![CDATA[<p>Discuz的代码还是比较容易看懂的。关键是要找到需要改的地方。<br />第1步：<br />forumdisplay.php，用来准备要显示的帖子列表，然后用forumdisplay.htm作为显示模板。<br />找到forumdisplay.php中的：<br />$query = $sdb-&gt;query("SELECT t.* FROM {$tablepre}threads t<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE t.fid='$fid' $filteradd AND $displayorderadd<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ORDER BY t.displayorder DESC, t.$orderby $ascdesc<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");</p>
<p>替换为：<br />$query = $sdb-&gt;query("SELECT t.*,min(att.attachment) as attm FROM {$tablepre}threads t<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LEFT JOIN {$tablepre}posts p ON p.tid=t.tid<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LEFT JOIN {$tablepre}attachments att ON att.tid=t.tid<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE t.fid='$fid' $filteradd AND $displayorderadd<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GROUP BY t.tid<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ORDER BY t.displayorder DESC, t.$orderby $ascdesc<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LIMIT ".($filterbool ? $start_limit : $start_limit - $stickycount).", $tpp");</p>
<p>意思很简单，把附件表中对应第一个附件选出来。这里有一点要注意，需要考虑附件类型，加一个图片类型的where条件即可。</p>
<p>第二步：<br />修改forumdisplay.htm<br />把第237行的：<br />&lt;span id="thread_$thread[tid]"&gt;&lt;a href="viewthread.php?tid=$thread[tid]&amp;amp;extra=$extra"$thread[highlight]&gt;$thread[subject]&lt;/a&gt;&lt;/span&gt;<br />替换为：<br />&lt;span id="thread_$thread[tid]"&gt;&lt;a href="viewthread.php?tid=$thread[tid]&amp;amp;extra=$extra"$thread[highlight]&gt;&lt;image width="100px" height="100px" src="attachments/$thread[attm]"/&gt;$thread[subject]&lt;/a&gt;&lt;/span&gt;<br />加个图片到链接里。</p>
<p>完成。</p>

	Tags: <a href="http://zhangv.com/archives/tag/discuz" title="discuz" rel="tag">discuz</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/1106/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>设置路径的vbs脚本</title>
		<link>http://zhangv.com/archives/739</link>
		<comments>http://zhangv.com/archives/739#comments</comments>
		<pubDate>Wed, 18 Mar 2009 14:28:00 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://zhangv.com/archives/739</guid>
		<description><![CDATA[下面这段vbs代码会将当前的目录加入到路径，同时添加一个新的环境变量，值为当前路径
Set WshShell = WScript.CreateObject("WScript.Shell")&#160; &#160; Set Env = WshShell.Environment("SYSTEM")&#160; &#160; WScript.Echo Env("Path")&#160; currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))&#160; Env("TODOR_BASE") = currentDirectory
currentPath = Env("Path")pos = InStr(currentPath,currentDirectory)if pos=0 then&#160;&#160;&#160; Env("Path") = currentPath &#38; ";" &#38; currentDirectoryend if
WScript.Echo "Setup successfully!"



	Tags: backup, vbscript, 代码
]]></description>
			<content:encoded><![CDATA[<p>下面这段vbs代码会将当前的目录加入到路径，同时添加一个新的环境变量，值为当前路径</p>
<p>Set WshShell = WScript.CreateObject("WScript.Shell")&nbsp; <br />&nbsp; <br />Set Env = WshShell.Environment("SYSTEM")&nbsp; <br />&nbsp; <br />WScript.Echo Env("Path")&nbsp; <br />currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))<br />&nbsp; <br />Env("TODOR_BASE") = currentDirectory</p>
<p>currentPath = Env("Path")<br />pos = InStr(currentPath,currentDirectory)<br />if pos=0 then<br />&nbsp;&nbsp;&nbsp; Env("Path") = currentPath &amp; ";" &amp; currentDirectory<br />end if</p>
<p>WScript.Echo "Setup successfully!"</p>
<p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=d3a3da99-0f4a-4f44-98c3-2d7366a597cb" /></div>

	Tags: <a href="http://zhangv.com/archives/tag/backup" title="backup" rel="tag">backup</a>, <a href="http://zhangv.com/archives/tag/vbscript" title="vbscript" rel="tag">vbscript</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/739/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>递归生成目录文件列表</title>
		<link>http://zhangv.com/archives/391</link>
		<comments>http://zhangv.com/archives/391#comments</comments>
		<pubDate>Sat, 05 Jul 2008 06:19:41 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://zhangv.com/?p=391</guid>
		<description><![CDATA[很早前在学校时候写的一个生成目录文件列表的东西，因为那时候自己开了一个ftp服务器。
&#160;
import java.util.Date;
import java.util.Arrays;
import java.io.*;
&#160;
/**
* Time: 2003-12-23 20:46:42
*/
public class FileManager &#123;
private String ListFilename = &#34;@list.txt&#34;;
private String root;
private String updatetime;
&#160;
public FileManager&#40;String root&#41; &#123;
this.root = root;
updatetime=new Date&#40;&#41;.toString&#40;&#41;;
&#125;
&#160;
private void getList&#40;String dir&#41; &#123;
File tmp = new File&#40;dir&#41;;
File&#91;&#93; files = tmp.listFiles&#40;new ffilter&#40;&#41;&#41;;
File&#91;&#93; dirs = tmp.listFiles&#40;new dfilter&#40;&#41;&#41;;
&#160;
if &#40;files.length != 0&#41; &#123;
writeListFile&#40;files&#41;;
&#125;
if &#40;dirs.length != 0&#41; &#123;
for &#40;int i = 0; i &#38;lt; dirs.length; [...]]]></description>
			<content:encoded><![CDATA[<p>很早前在学校时候写的一个生成目录文件列表的东西，因为那时候自己开了一个ftp服务器。</p>
<pre class="java">&nbsp;
<span style="color: #a1a100;">import java.util.Date;</span>
<span style="color: #a1a100;">import java.util.Arrays;</span>
<span style="color: #a1a100;">import java.io.*;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/**
* Time: 2003-12-23 20:46:42
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FileManager <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> ListFilename = <span style="color: #ff0000;">&quot;@list.txt&quot;</span>;
<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> root;
<span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> updatetime;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> FileManager<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> root<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">root</span> = root;
updatetime=<span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> getList<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> dir<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a> tmp = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#40;</span>dir<span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> files = tmp.<span style="color: #006600;">listFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ffilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> dirs = tmp.<span style="color: #006600;">listFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> dfilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>files.<span style="color: #006600;">length</span> != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
writeListFile<span style="color: #66cc66;">&#40;</span>files<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dirs.<span style="color: #006600;">length</span> != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &amp;lt; dirs.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
getList<span style="color: #66cc66;">&#40;</span>tmp.<span style="color: #006600;">getPath</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;/&quot;</span> + dirs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> writeListFile<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> files<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileWriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileWriter</span></a> f = <span style="color: #000000; font-weight: bold;">null</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> parent = files<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getParent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #993333;">int</span> size;
f = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileWriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileWriter</span></a><span style="color: #66cc66;">&#40;</span>parent +<span style="color: #ff0000;">&quot;/&quot;</span>+ListFilename<span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;【列表最后更新时间】&quot;</span>+<span style="color: #ff0000;">&quot; :&quot;</span>+updatetime<span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;【欢迎分享我的收藏】，enjoy!&quot;</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">//排列顺序</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AArrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Arrays</span></a>.<span style="color: #006600;">sort</span><span style="color: #66cc66;">&#40;</span>files<span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &amp;lt; files.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span>files<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
size = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span> files<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot; 【size:&quot;</span>+size/<span style="color: #cc66cc;">1000</span>+<span style="color: #ff0000;">&quot;k】&quot;</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
f.<span style="color: #006600;">flush</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileNotFoundException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileNotFoundException</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;file not found&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> run<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
delete<span style="color: #66cc66;">&#40;</span>root<span style="color: #66cc66;">&#41;</span>;
getList<span style="color: #66cc66;">&#40;</span>root<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> delete<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> dir<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a> tmp = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#40;</span>dir<span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a> lfile = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#40;</span>dir + <span style="color: #ff0000;">&quot;/&quot;</span> + ListFilename<span style="color: #66cc66;">&#41;</span>;
lfile.<span style="color: #006600;">delete</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> dirs = tmp.<span style="color: #006600;">listFiles</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> dfilter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>dirs.<span style="color: #006600;">length</span> != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>; i &amp;lt; dirs.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span>
delete<span style="color: #66cc66;">&#40;</span>tmp.<span style="color: #006600;">getPath</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #ff0000;">&quot;/&quot;</span> + dirs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> args<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">/*      String dowhat = &quot;list&quot;;
if (args[0] != null) Root = args[0];
if (args[1] != null) dowhat = args[1];
FileManager f = new FileManager(Root);
if (args[1] == &quot;list&quot;)
f.getList(Root);
else if (args[1] == &quot;delete&quot;) f.delete(Root);*/</span>
&nbsp;
FileManager f=<span style="color: #000000; font-weight: bold;">new</span> FileManager<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">run</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ffilter <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileFilter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileFilter</span></a> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> accept<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a> pathname<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name = pathname.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>pathname.<span style="color: #006600;">isFile</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> &amp;amp;&amp;amp; <span style="color: #66cc66;">&#40;</span>name.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.mp3&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> dfilter <span style="color: #000000; font-weight: bold;">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFileFilter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">FileFilter</span></a> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> accept<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AFile+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">File</span></a> pathname<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> pathname.<span style="color: #006600;">isDirectory</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>

	Tags: <a href="http://zhangv.com/archives/tag/java" title="Java" rel="tag">Java</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/391/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>moder &#8211; 算利息</title>
		<link>http://zhangv.com/archives/332</link>
		<comments>http://zhangv.com/archives/332#comments</comments>
		<pubDate>Wed, 11 Jun 2008 02:12:30 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[moder]]></category>
		<category><![CDATA[swt]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://zhangv.com/?p=332</guid>
		<description><![CDATA[用swt作了一个算利息的东东
moder

	Tags: moder, swt, 代码
]]></description>
			<content:encoded><![CDATA[<p>用swt作了一个算利息的东东</p>
<p><a href="http://zhangv.com/wordpress/wp-content/uploads/moder.zip">moder</a></p>

	Tags: <a href="http://zhangv.com/archives/tag/moder" title="moder" rel="tag">moder</a>, <a href="http://zhangv.com/archives/tag/swt" title="swt" rel="tag">swt</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/332/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简单的div显示，隐藏例子</title>
		<link>http://zhangv.com/archives/78</link>
		<comments>http://zhangv.com/archives/78#comments</comments>
		<pubDate>Fri, 14 Dec 2007 08:39:19 +0000</pubDate>
		<dc:creator>zhangv</dc:creator>
				<category><![CDATA[技术(Tech)]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://218.22.170.60/zhangv/wordpress/?p=96</guid>
		<description><![CDATA[&#60;script type="text/javascript" language="JavaScript"&#62;&#60;!--
function HideContent(d) {
if(d.length &#60; 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length &#60; 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay0(d) {
if(d.length &#60; 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
function ReverseContentDisplay(d) {
if(d.length &#60; 1) { return; }
for(i=1;i&#60;=3;i++){
var tmp = 'block'+i;
if(d==tmp){
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;script type="text/javascript" language="JavaScript"&gt;&lt;!--<br />
function HideContent(d) {<br />
if(d.length &lt; 1) { return; }<br />
document.getElementById(d).style.display = "none";<br />
}<br />
function ShowContent(d) {<br />
if(d.length &lt; 1) { return; }<br />
document.getElementById(d).style.display = "block";<br />
}<br />
function ReverseContentDisplay0(d) {<br />
if(d.length &lt; 1) { return; }<br />
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }<br />
else { document.getElementById(d).style.display = "none"; }<br />
}</p>
<p>function ReverseContentDisplay(d) {<br />
if(d.length &lt; 1) { return; }<br />
for(i=1;i&lt;=3;i++){<br />
var tmp = 'block'+i;<br />
if(d==tmp){<br />
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }<br />
else { document.getElementById(d).style.display = "none"; }<br />
}else{<br />
document.getElementById(tmp).style.display = "none";<br />
}<br />
}<br />
}<br />
//--&gt;&lt;/script&gt;</p>
<p>&lt;a<br />
onclick="javascript:ReverseContentDisplay('block1'); return true;"<br />
href="#"&gt;<br />
[Bid 1]<br />
&lt;/a&gt;<br />
&lt;div<br />
id="block1"<br />
style="display:none;<br />
border-style: solid;<br />
background-color: white;<br />
padding: 5px;"&gt;</p>
<p>bLOCK 1<br />
&lt;/div&gt;<br />
&lt;br&gt;<br />
&lt;a<br />
onclick="javascript:ReverseContentDisplay('block2'); return true;"<br />
href="#"&gt;<br />
[Bid 2]<br />
&lt;/a&gt;<br />
&lt;div<br />
id="block2"<br />
style="display:none;<br />
border-style: solid;<br />
background-color: white;<br />
padding: 5px;"&gt;</p>
<p>bLOCK 2<br />
&lt;/div&gt;<br />
&lt;br&gt;<br />
&lt;a<br />
onclick="javascript:ReverseContentDisplay('block3'); return true;"<br />
href="#"&gt;<br />
[Bid 3]<br />
&lt;/a&gt;<br />
&lt;div<br />
id="block3"<br />
style="display:none;<br />
border-style: solid;<br />
background-color: white;<br />
padding: 5px;"&gt;</p>
<p>bLOCK 3<br />
&lt;/div&gt;</p>

	Tags: <a href="http://zhangv.com/archives/tag/webdev" title="webdev" rel="tag">webdev</a>, <a href="http://zhangv.com/archives/tag/%e4%bb%a3%e7%a0%81" title="代码" rel="tag">代码</a><br />
]]></content:encoded>
			<wfw:commentRss>http://zhangv.com/archives/78/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

