ファイルの各行にある8桁の数字がある場合に出力して、カウントしてみました。 2007/10/30

ファイルの各行にある8桁の数字がある場合に出力して、カウントしてみました。

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class T {

public static void main(String[] args) throws IOException {
a();
}

public static void a() throws IOException {
InputStream inputStream = T.class.getResourceAsStream("PID.log");
BufferedReader reader = new BufferedReader(new InputStreamReader(
inputStream));
String line = null;
int cnt = 0;
while ((line = reader.readLine()) != null) {

if (line.matches("^[0-9]{8}")) {
System.out.println(line);
cnt++;
}

}
System.err.printf("count:%d%n", cnt);
reader.close();

}

}

: