1
import java.io.*;
2
import java.util.*;
3
public class MainClass
{
4
5
/** *//**
6
* @param args
7
*/
8
static Thread t1 = new Thread();
9
static String Path = null;
10
static String subStr = null;
11
12
public static void main(String[] args)
{
13
FileWriter fout = null;
14
BufferedWriter fout_2 = null;
15
try
{
16
fout = new FileWriter("D:\\ans.txt");
17
fout_2 = new BufferedWriter(fout);
18
} catch (IOException e)
{
19
// TODO Auto-generated catch block
20
e.printStackTrace();
21
}
22
Scanner reader = new Scanner(System.in);
23
while(reader.hasNext())
{
24
Path = reader.nextLine();
25
subStr = reader.nextLine();
26
}
27
28
File f1 = new File(Path);
29
ListDfs(f1,fout_2);
30
try
{
31
fout_2.close();
32
fout.close();
33
} catch (IOException e)
{
34
// TODO Auto-generated catch block
35
e.printStackTrace();
36
}
37
}
38
static void ListDfs(File root,BufferedWriter fout)
{
39
40
String [] resArg = null;
41
FilenameFilter obj = new FilenameFilter(subStr);
42
43
File [] arg = root.listFiles();
44
for(int i=0;arg!=null && i<arg.length;i++)
{
45
if( arg[i].isDirectory() )
{
46
ListDfs(arg[i],fout);
47
System.out.println("/* "+arg[i].getAbsolutePath()+" */");
48
try
{
49
t1.sleep(50);
50
} catch (InterruptedException e)
{
51
// TODO Auto-generated catch block
52
e.printStackTrace();
53
}
54
}
55
if( arg[i].isFile() )
{
56
if( obj.accept(arg[i], arg[i].getName()) == true )
{
57
System.out.println(arg[i].getName());
58
try
{
59
fout.write(arg[i].getName()+"\r\n");
60
} catch (IOException e)
{
61
// TODO Auto-generated catch block
62
e.printStackTrace();
63
}
64
}
65
}
66
67
}
68
}
69
}
70
71

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

44



45



46

47

48



49

50



51

52

53

54

55



56



57

58



59

60



61

62

63

64

65

66

67

68

69

70

71
