home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2003 April / PFA0304.iso / fullversioner / ImageZoom / InstData / com / utility / ZGProcess.class (.txt) < prev   
Encoding:
Java Class File  |  2002-07-17  |  1.8 KB  |  112 lines

  1. package com.zerog.ia.download.utility;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. public class ZGProcess {
  7.    // $FF: renamed from: p java.lang.Process
  8.    Process field_0;
  9.    // $FF: renamed from: is java.io.InputStream
  10.    InputStream field_1;
  11.    int maxWait;
  12.    int totalSleepTime;
  13.  
  14.    public ZGProcess(String var1) throws IOException {
  15.       this(var1, 3000);
  16.    }
  17.  
  18.    public ZGProcess(String var1, int var2) throws IOException {
  19.       this.field_0 = null;
  20.       this.field_1 = null;
  21.       this.maxWait = 3000;
  22.       this.totalSleepTime = 0;
  23.  
  24.       try {
  25.          this.field_0 = Runtime.getRuntime().exec(var1);
  26.       } catch (IOException var4) {
  27.       }
  28.  
  29.       this.field_1 = this.field_0.getInputStream();
  30.       this.maxWait = var2;
  31.    }
  32.  
  33.    public InputStream getInputStream() {
  34.       return this.field_1;
  35.    }
  36.  
  37.    private int getChar() {
  38.       byte var1 = 50;
  39.       char var2 = 0;
  40.  
  41.       while(!this.dataWaiting() && this.totalSleepTime < this.maxWait) {
  42.          try {
  43.             Thread.sleep((long)var1);
  44.             this.totalSleepTime += var1;
  45.          } catch (Exception var5) {
  46.          }
  47.       }
  48.  
  49.       if (!this.dataWaiting()) {
  50.          return -1;
  51.       } else {
  52.          try {
  53.             var2 = (char)this.field_1.read();
  54.          } catch (Exception var4) {
  55.          }
  56.  
  57.          return var2;
  58.       }
  59.    }
  60.  
  61.    public String getLine() {
  62.       boolean var1 = false;
  63.       StringBuffer var2 = new StringBuffer();
  64.       if (this.isDone() && !this.dataWaiting()) {
  65.          return null;
  66.       } else {
  67.          for(int var3 = this.getChar(); this.totalSleepTime < this.maxWait && var3 > 0 && var3 != 10; var3 = this.getChar()) {
  68.             var2.append((char)var3);
  69.          }
  70.  
  71.          return var2.toString();
  72.       }
  73.    }
  74.  
  75.    private boolean dataWaiting() {
  76.       try {
  77.          if (this.field_1.available() > 0) {
  78.             return true;
  79.          }
  80.       } catch (IOException var2) {
  81.       }
  82.  
  83.       return false;
  84.    }
  85.  
  86.    private boolean isDone() {
  87.       try {
  88.          this.field_0.exitValue();
  89.          return true;
  90.       } catch (IllegalThreadStateException var2) {
  91.          return false;
  92.       }
  93.    }
  94.  
  95.    private int exitValue() throws IllegalThreadStateException {
  96.       return this.field_0.exitValue();
  97.    }
  98.  
  99.    private static String concatenateCmdLine(String[] var0) {
  100.       int var1 = var0.length;
  101.       StringBuffer var2 = new StringBuffer();
  102.       Object var3 = null;
  103.  
  104.       for(int var4 = 0; var4 < var1; ++var4) {
  105.          var2.append(var0[var4] + " ");
  106.       }
  107.  
  108.       String var5 = var2.toString();
  109.       return var5.substring(0, var5.length() - 1);
  110.    }
  111. }
  112.