Exemple #1
0
 public function count($inFile, $outFile)
 {
     $reader = new LineReader($inFile);
     $writer = new BufferedFileWriter($outFile);
     $prev = $reader->current();
     $n = 1;
     $reader->next();
     while ($reader->valid()) {
         if (strcmp($reader->current(), $prev) == 0) {
             $n++;
         } else {
             $writer->write($prev . ' ' . $n . "\n");
             $prev = $reader->current();
             $n = 1;
         }
         $reader->next();
     }
     $writer->close();
 }
Exemple #2
0
 private function copyChunk($file1, $outFile)
 {
     $chunk1 = new LineReader($file1);
     $out = new BufferedFileWriter($outFile);
     while ($chunk1->valid()) {
         $out->write($chunk1->current() . "\n");
         $chunk1->next();
     }
     $chunk1->close();
     unlink($file1);
     $out->close();
 }