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

  1. package com.sfs.net;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.net.MalformedURLException;
  7. import java.net.URL;
  8. import java.util.Enumeration;
  9. import java.util.StringTokenizer;
  10. import java.util.Vector;
  11.  
  12. public class StreamParser implements Enumeration {
  13.    public static final String TOKEN_BREAK = "┬░";
  14.    BufferedReader dis;
  15.    Vector args;
  16.  
  17.    public Object nextElement() {
  18.       return this.args;
  19.    }
  20.  
  21.    public boolean hasMoreElements() {
  22.       try {
  23.          while(true) {
  24.             String var1;
  25.             if ((var1 = this.dis.readLine()) != null) {
  26.                this.args = this.parseLine(var1);
  27.                if (this.args == null) {
  28.                   continue;
  29.                }
  30.             }
  31.  
  32.             if (var1 != null && this.args != null) {
  33.                break;
  34.             }
  35.  
  36.             this.dis.close();
  37.             return false;
  38.          }
  39.       } catch (IOException var4) {
  40.          System.out.println("IOException: " + var4);
  41.       }
  42.  
  43.       return true;
  44.    }
  45.  
  46.    public StreamParser(URL var1) throws IOException {
  47.       try {
  48.          this.dis = new BufferedReader(new InputStreamReader(var1.openStream()));
  49.       } catch (MalformedURLException var4) {
  50.          System.out.println("MalformedURLException: " + var4);
  51.       } catch (IOException var5) {
  52.          System.out.println("IOException: " + var5);
  53.       }
  54.    }
  55.  
  56.    Vector parseLine(String var1) {
  57.       if (!var1.startsWith("//") && !var1.equals("")) {
  58.          StringTokenizer var2 = new StringTokenizer(var1, "┬░");
  59.          Vector var3 = new Vector();
  60.  
  61.          while(var2.hasMoreTokens()) {
  62.             var3.addElement(var2.nextToken());
  63.          }
  64.  
  65.          return var3.size() == 0 ? null : var3;
  66.       } else {
  67.          return null;
  68.       }
  69.    }
  70. }
  71.