コード例 #1
0
ファイル: FileLines.java プロジェクト: satriov/aida
 /** returns number of lines in file */
 public static int numAllFileLines(File f, String ext) throws IOException {
   if (f.isFile()) return (f.getName().endsWith(ext) ? numFileLines(f) : 0);
   int counter = 0;
   Announce.doing("Counting in", f);
   for (File f2 : f.listFiles()) {
     counter += numAllFileLines(f2, ext);
   }
   Announce.done();
   return (counter);
 }
コード例 #2
0
ファイル: FileLines.java プロジェクト: satriov/aida
 /** Constructs FileLines from a file, shows progress bar (main constructor 2) */
 public FileLines(File f, String announceMsg) throws IOException {
   if (announceMsg != null) {
     Announce.progressStart(announceMsg, f.length());
     announceChars = 0;
   }
   br = new BufferedReader(new FileReader(f));
 }
コード例 #3
0
ファイル: FileLines.java プロジェクト: satriov/aida
 /** Closes the reader */
 public void close() {
   try {
     br.close();
   } catch (IOException e) {
   }
   if (announceChars != -1) Announce.progressDone();
   announceChars = -1;
 }
コード例 #4
0
ファイル: FileLines.java プロジェクト: satriov/aida
 /**
  * Returns next line. In case of an IOException, the exception is wrapped in a RuntimeException
  */
 public String internalNext() {
   String next;
   try {
     next = br.readLine();
     if (announceChars != -1 && next != null) Announce.progressAt(announceChars += next.length());
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   return (next);
 }