Robin's Programming World
I Love Programming As My Life!
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆-193 評論-715 文章-1 trackbacks-0
文件比較器V0.1版
昨天晚上實(shí)在太無聊了,想著自己的移動硬盤和公司的電腦里面資料有很多不“同步”,要是刪掉移動硬盤里面的文件然后再把所有的文件COPY一次的話,估計得幾個小時,USB的速度畢竟還慢,而且沒有必要都COPY,從時間和性能上都很不劃算。
怎么辦?
寫個程序吧來解決吧(很多時候我總想著用程序來解決問題)。
程序很簡單,僅滿足我現(xiàn)在的基本功能,將比較的結(jié)果打印成清單。如果你也有同想的需求,你可以免費(fèi)使用她,我可能會在將來的時間里做成圖形化的界面,目前會JAVA的人都可以使用。
暫定版本為 文件比較器 V0.1。源程序如下:
1
import
java.io.
*
;
2
3
/**/
/*
4
作者:張明星
5
時間:2006.3.12.
6
*/
7
public
class
FileCompare
{
8
9
public
FileCompare(String pathName,String destPathName)
{
10
this
.compare(pathName,destPathName);
11
}
12
13
public
void
compare(String pathName,String destPathName)
{
14
try
{
15
File file
=
new
File(pathName);
16
17
String fileAbsolutePath
=
file.getAbsolutePath();
18
19
String []fileList
=
file.list();
20
for
(
int
i
=
0
;i
<
fileList.length;i
++
)
{
21
File tempFile
=
new
File(fileAbsolutePath,fileList[i]);
22
if
(tempFile.isDirectory())
{
23
File tempFile1
=
new
File(destPathName
+
tempFile.getAbsolutePath().substring(pathName.length()));
24
if
(
!
tempFile1.exists())
25
//
tempFile1.mkdir();
//
可建立此目錄
26
System.out.println(tempFile1.getAbsolutePath()
+
"
,此文件目錄不存在。
"
);
27
this
.compare(tempFile.getAbsolutePath(),destPathName
+
tempFile.getAbsolutePath().substring(pathName.length()));
28
}
29
else
if
(tempFile.isFile())
{
30
File tempFile2
=
new
File(destPathName
+
tempFile.getAbsolutePath().substring(pathName.length()));
31
if
(
!
tempFile2.exists())
32
System.out.println(tempFile.getAbsolutePath()
+
"
,目標(biāo)文件夾中無此文件。
"
);
33
}
34
else
{
35
System.out.println(
"
Error
"
);
36
}
37
}
38
}
39
catch
(Exception e)
{
40
e.printStackTrace();
41
}
42
}
43
public
static
void
main(String[] args)
{
//第一個參數(shù)為源目錄,第二個參數(shù)為目標(biāo)目錄。
44
new
FileCompare(
"
D:\\software
"
,
"
L:\\software
"
);
45
System.exit(
0
);
46
}
47
48
}
49
同時也歡迎大家拍磚和交流:
MSN:
fastzch@hotmail.com
posted on 2006-03-12 11:20
Robin's Programming World
閱讀(1915)
評論(6)
編輯
收藏
所屬分類:
Java
評論:
#
re: 文件比較器V0.1版 2006-03-12 17:14 |
thinkbase
有一個叫做 JFileSync 的東東可以滿足你的需求, 而且功能比較強(qiáng)大
回復(fù)
更多評論
#
re: 文件比較器V0.1版 2006-03-13 10:07 |
Robin's Java World
這東東的確不錯,謝謝!
有空來研究一下其源碼。
回復(fù)
更多評論
#
re: 文件比較器V0.1版 2006-03-13 10:24 |
guest
直接用xcopy命令就可以搞定了,我就xcopy來同步筆記本和臺式機(jī)資料的。
回復(fù)
更多評論
#
re: 文件比較器V0.1版 2006-03-13 10:27 |
guest
xcopy d:\src e:\dest /H /R /D /E
回復(fù)
更多評論
#
re: 文件比較器V0.1版 2006-03-13 18:27 |
calvin
以后此類小程序代碼請勿放在blogjava首頁,謝謝:)
回復(fù)
更多評論
#
re: 文件比較器V0.1版
2006-03-14 16:10 |
Robin's Java World
XCOPY的確不錯,不過我如果某些部分不想要的話就不好辦了。
我已經(jīng)把JFileSync這個東東打好包了,做成了個窗口圖形程序,不過公司的網(wǎng)絡(luò)過濾太嚴(yán),不太好上傳,改天找個機(jī)會傳上去吧。
回復(fù)
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
Ubuntu環(huán)境下Apache2與Tomcat集成
Spring 3 MVC and JSON example
Android Media Player 深入觀察
[轉(zhuǎn)]編寫高效的Android代碼
Android程序完全退出的三種方法
使用ANT批量編譯Flex應(yīng)用和模塊(Use ANT to batch compiling application and modules of Flex)
Investigate getDeclaredMethod of Java Reflection
Eclipse空心J圖標(biāo)的含義
Memcached Study Notes
BlazeDS自定義認(rèn)證與權(quán)限控制
<
2006年3月
>
日
一
二
三
四
五
六
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(49)
給我留言
查看公開留言
查看私人留言
隨筆分類
(215)
.Net(1)
DB(8)
Flex & Flash(11)
Java(72)
OS(25)
RUP(1)
weblogic(3)
Webshere(16)
其它(50)
心情(2)
翻譯(1)
讀書(9)
轉(zhuǎn)載(16)
隨筆檔案
(181)
2014年8月 (1)
2014年4月 (1)
2014年2月 (2)
2014年1月 (1)
2012年11月 (1)
2012年9月 (2)
2012年7月 (1)
2012年6月 (3)
2012年1月 (2)
2011年12月 (4)
2011年10月 (1)
2011年8月 (3)
2011年7月 (2)
2011年4月 (1)
2010年11月 (2)
2010年10月 (1)
2010年9月 (2)
2010年8月 (5)
2010年7月 (1)
2010年5月 (2)
2010年4月 (7)
2010年3月 (7)
2009年12月 (6)
2009年10月 (1)
2009年9月 (1)
2009年8月 (2)
2009年6月 (3)
2009年5月 (2)
2009年4月 (2)
2009年2月 (3)
2009年1月 (4)
2008年11月 (1)
2008年10月 (2)
2008年9月 (9)
2008年8月 (4)
2008年7月 (5)
2008年5月 (2)
2008年4月 (1)
2008年3月 (3)
2008年2月 (1)
2008年1月 (7)
2007年12月 (6)
2007年11月 (6)
2007年10月 (3)
2007年9月 (1)
2007年8月 (6)
2007年7月 (4)
2007年6月 (2)
2007年5月 (3)
2007年3月 (1)
2007年2月 (1)
2007年1月 (3)
2006年12月 (7)
2006年10月 (1)
2006年8月 (3)
2006年7月 (1)
2006年6月 (5)
2006年4月 (6)
2006年3月 (2)
2006年2月 (3)
2006年1月 (1)
2005年11月 (5)
相冊
文章相關(guān)圖片
收藏夾
other
Friend Links
Tiger的Blog,專注于過程改進(jìn),項(xiàng)目管理,質(zhì)量管理三個方向。
zrfunds
搜索
積分與排名
積分 - 756278
排名 - 60
最新評論
1.?re: XFire完整入門教程
樓主,請問你做過xfire使用spring的jdbc模板訪問數(shù)據(jù)庫的例子嗎,急求啊?xfire和spring的結(jié)合在不訪問數(shù)據(jù)庫時(就像你這個例子一樣)已經(jīng)跑通了,但是需要使用jdbc時老出問題。謝謝
--fqjabc
2.?re: 一次JQuery性能優(yōu)化實(shí)戰(zhàn)
不需要構(gòu)建DOM
--bns
3.?re: Spring Security 3.x 完整入門教程
@過客
尊重人是最起碼的
--bns
4.?re: Flex中帶有三種狀態(tài)CheckBox的Tree的實(shí)現(xiàn)
帶有3種狀態(tài)CheckBox的樹形組件剛好用到
收了
--bns
5.?re: Spring Security 3.x 完整入門教程
AntUrlPathMatcher這個類所在jar包是哪個啊,是spring-security-core-tiger這個嗎?
--iechenyb
閱讀排行榜
1.?XFire完整入門教程(90523)
2.?Spring Security 3.x 完整入門教程(59208)
3.?使用XFire開發(fā)Web Service客戶端完整入門教程(52362)
4.?WebSphere6.1中使用Spring報cvc-elt.1: Cannot find the declaration of element 'beans'異常的解決辦法(24265)
5.?用MKVMerge GUI合并MKV文件(16694)
評論排行榜
1.?XFire完整入門教程(130)
2.?Spring Security 3.x 完整入門教程(67)
3.?使用XFire開發(fā)Web Service客戶端完整入門教程(33)
4.?VBA編程心得(24)
5.?JDK1.5API完整中文版CHM格式文檔發(fā)放(可下載)(22)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 Robin's Programming World
主站蜘蛛池模板:
雷山县
|
云龙县
|
宁波市
|
丽江市
|
任丘市
|
双流县
|
大兴区
|
德江县
|
紫阳县
|
黄山市
|
临湘市
|
申扎县
|
桦川县
|
宁波市
|
彭泽县
|
璧山县
|
十堰市
|
尚志市
|
靖宇县
|
湾仔区
|
安顺市
|
平南县
|
瑞昌市
|
灵台县
|
泌阳县
|
塔河县
|
色达县
|
岑溪市
|
福安市
|
两当县
|
安陆市
|
府谷县
|
司法
|
玉林市
|
永平县
|
清水县
|
沙田区
|
教育
|
玛多县
|
大城县
|
涿鹿县
|