home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / WIN95 / IAVAZIP.EXE / DATA.Z / TxtView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-18  |  2.2 KB  |  90 lines

  1. package com.sfs.iavazip.viewer;
  2.  
  3. import com.sfs.debug.Debug;
  4. import java.awt.BorderLayout;
  5. import java.awt.Color;
  6. import java.awt.Component;
  7. import java.awt.Container;
  8. import java.awt.Frame;
  9. import java.awt.TextArea;
  10. import java.io.FileNotFoundException;
  11. import java.io.FileReader;
  12. import java.io.IOException;
  13. import java.io.LineNumberReader;
  14.  
  15. public class TxtView extends Viewer implements Runnable {
  16.    LineNumberReader lnr;
  17.    // $FF: renamed from: fr java.io.FileReader
  18.    FileReader field_0;
  19.    Thread thread;
  20.    String fileName;
  21.    // $FF: renamed from: ta java.awt.TextArea
  22.    TextArea field_1;
  23.  
  24.    public void setArgs(Frame var1, String var2) {
  25.       try {
  26.          this.lnr = new LineNumberReader(this.field_0 = new FileReader(var2));
  27.       } catch (FileNotFoundException var3) {
  28.          Debug.Info("cannot open file \"" + var2 + "\"");
  29.          this.lnr = null;
  30.          return;
  31.       }
  32.  
  33.       ((Container)this).setLayout(new BorderLayout());
  34.       ((Container)this).add(this.field_1 = new TextArea());
  35.       this.field_1.setEditable(false);
  36.       this.field_1.setBackground(Color.white);
  37.       this.fileName = var2;
  38.       this.thread = new Thread(this);
  39.       this.thread.start();
  40.    }
  41.  
  42.    public void flush() {
  43.       this.thread.stop();
  44.       if (this.lnr != null) {
  45.          try {
  46.             this.lnr.close();
  47.             this.field_0.close();
  48.             return;
  49.          } catch (IOException var3) {
  50.             Debug.Info("TxtView.flush() failed during " + ((Throwable)var3).getMessage());
  51.          }
  52.       }
  53.  
  54.    }
  55.  
  56.    public void run() {
  57.       try {
  58.          String var2;
  59.          do {
  60.             Thread.sleep(50L);
  61.             ((Component)this).repaint();
  62.             int var1 = 0;
  63.             var2 = null;
  64.             String var3 = "";
  65.  
  66.             try {
  67.                while((var2 = this.lnr.readLine()) != null) {
  68.                   var3 = var3 + var2 + System.getProperty("line.separator");
  69.                   if (var1++ == 50) {
  70.                      this.field_1.append(var3);
  71.                      break;
  72.                   }
  73.                }
  74.  
  75.                if (var2 == null) {
  76.                   this.field_1.append(var3);
  77.                }
  78.             } catch (IOException var4) {
  79.                this.flush();
  80.                Debug.Info("iss was dazwischen gefunkt");
  81.             }
  82.          } while(var2 != null);
  83.  
  84.          this.flush();
  85.       } catch (InterruptedException var5) {
  86.          this.flush();
  87.       }
  88.    }
  89. }
  90.