Dear Mr. Pig, just for your reference

jabber (jabber)
The following is the code that may be useful to some people. My code is not polished. If you are a coding expert, please do not comment on the stupidness in my code. Thank you.

import java.io.*;

public class FileCount{

private static int javacount=0;

public static void main(String[] args) throws Exception{
if(args.length !=1) {
System.out.println("usge: java FileCount <dir>");
return;
}
File file = new File(args[0]);
count(file);
System.out.println("There are " + javacount + " java files under "+ args[0]);

}

private static void count(File f)throws Exception{
File list[] = f.listFiles();
for(int i=0; i<list.length; i++) {
if(list[i].isDirectory()) {
count(list[i]);
} else{
String s = list[i].getName();
int index = s.indexOf(".java");
if(index !=-1) {
javacount++;
}

}
}

}
(#177232@0)
2001-8-23 -05:00

回到话题: Jabber's English Note---035

回到论坛: HOME枫下论坛枫下论坛主坛工作学习English

URL:   
http://www.rolia.net/zh/post.php?f=0&p=177232