예제 #1
0
  /**
   * Run with "java com.spruenker.gtimelog.reporter.Reporter -i "~/.gtimelog/timelog.txt"
   *
   * @param args First (and only) argument is the location of you timelog.txt file.
   */
  public static void main(String[] args) {

    // Parse command line arguments
    parseArgs(args);

    // Read gtimelog-file
    Report report = importFromFile();

    // Generate and print report
    printer.print(formatter.format(report.getPeriod(period)));
  }
예제 #2
0
 /**
  * Reads the timelog.txt and returns its content as a Report-Object.
  *
  * @return Report
  */
 private static Report importFromFile() {
   Report report = new Report();
   try {
     BufferedReader br = new BufferedReader(new FileReader(file));
     String line;
     line = br.readLine();
     while (line != null) {
       report.addLogEntry(line);
       line = br.readLine();
     }
     br.close();
   } catch (FileNotFoundException e) {
     System.out.println("Could not find " + file);
     e.printStackTrace();
   } catch (IOException e) {
     System.out.println("Could not open " + file);
     e.printStackTrace();
   }
   return report;
 }