자바 통계 폴 더 의 파일 총 줄 수
1094 단어 자바
//By LYLtim
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class TestIO {
static BufferedReader BR = null;
static long Count = 0;
public static void main(String[] args) throws IOException {
Trvs(new File("D:/Temp/LYLtim_OI"));
System.out.print(Count);
}
static void Trvs(File f) throws IOException {
File[] childs = f.listFiles();
for (int i = 0; i < childs.length; i++) {
if (childs[i].isFile()) {
BR = new BufferedReader(new FileReader(childs[i]));
while (BR.readLine() != null) Count += 1;
}
else Trvs(childs[i]);
}
}
}
결과:8258
내 가 생각 했 던 몇 만 줄 보다 적은 데...> <
그러나 내 가《올림픽 클래식》을 만 든 코드 는 내 가 잘못 삭제 한 것 으로 계산 되 지 않 았 다.게다가 만 줄 에 도 있다.