01: package org.acm.seguin.metrics;
02:
03: import java.io.File;
04: import java.io.FileReader;
05: import java.io.BufferedReader;
06: import java.io.IOException;
07:
08: public class Summarize {
09: private File dir;
10:
11: public Summarize(String dirName) {
12: dir = new File(dirName);
13: }
14:
15: public void run() {
16: File[] list = dir.listFiles();
17: for (int ndx = 0; ndx < list.length; ndx++) {
18: extractTotals(list[ndx]);
19: }
20: }
21:
22: private void extractTotals(File input) {
23: try {
24: BufferedReader bufferedReader = new BufferedReader(
25: new FileReader(input));
26: String name = input.getName();
27: name = name.substring(0, name.indexOf(".csv"));
28:
29: String line = bufferedReader.readLine();
30: while (line != null) {
31: if (line.indexOf("---,---,---") >= 0) {
32: System.out.println(name + "," + line);
33: }
34: line = bufferedReader.readLine();
35: }
36:
37: bufferedReader.close();
38: } catch (IOException ioe) {
39: }
40: }
41:
42: public static void main(String[] args) {
43: if (args.length == 0) {
44: System.out
45: .println("Syntax: org.acm.seguin.metrics.Summarize <dir>");
46: } else {
47: (new Summarize(args[0])).run();
48: }
49: }
50: }
|