Beispiel #1
0
        private CloseOp closefile;  // handle to call cleanup method when finished reading

        public FileReader(TextFile f, CloseOp c)
        {
            this.f = f; count = 0; closefile = c;
        }
Beispiel #2
0
 // factory method to manufacture a helper reader object,
 // where  c  is the method to call when reading is finished
 public FileReader makeReader(CloseOp c)
 {
     return(new FileReader(this, c));
 }
Beispiel #3
0
 // factory method to manufacture a helper writer object,
 // where  c  is the method to call when writing is finished
 public FileWriter makeWriter(CloseOp c)
 {
     return(new FileWriter(this, c));
 }
        private CloseOp closefile; // cleanup method that is called when writing done

        public FileWriter(TextFile f, CloseOp c)
        {
            closefile = c;
            this.f    = f;
            this.f.reset();
        }