FileDocCategorySizeDatePackage
tab_separated_values.javaAPI DocExample1151Sat Sep 09 21:21:20 BST 2000com.macfaq.net.www.content.text

tab_separated_values

public class tab_separated_values extends ContentHandler

Fields Summary
Constructors Summary
Methods Summary
public java.lang.ObjectgetContent(java.net.URLConnection uc)


    String theLine;
    Vector v = new Vector();

    InputStreamReader isr = new InputStreamReader(uc.getInputStream());
    SafeBufferedReader in = new SafeBufferedReader(isr);
    while ((theLine = in.readLine()) != null) {
      String[] linearray = lineToArray(theLine);
      v.addElement(linearray);
    }

    return v; 

  
private java.lang.String[]lineToArray(java.lang.String line)


    int numFields = 1;
    for (int i = 0; i < line.length(); i++) {
      if (line.charAt(i) == '\t") numFields++;
    }
    String[] fields = new String[numFields];
    int position = 0;
    for (int i = 0; i < numFields; i++) {
      StringBuffer buffer = new StringBuffer();
      while (position < line.length() && line.charAt(position) != '\t") {
        buffer.append(line.charAt(position));
        position++;
      }
      fields[i] = buffer.toString();
      position++;
    }

    return fields;