怎么辦?
寫個程序吧來解決吧(很多時候我總想著用程序來解決問題)。
程序很簡單,僅滿足我現(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

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

32

33

34



35

36

37

38

39



40

41

42

43



//第一個參數(shù)為源目錄,第二個參數(shù)為目標(biāo)目錄。
44

45

46

47

48

49

同時也歡迎大家拍磚和交流:
MSN:fastzch@hotmail.com