FileDocCategorySizeDatePackage
tabSeparatedValueHandler.javaAPI DocExample831Thu Apr 03 15:27:58 BST 1997None

tabSeparatedValueHandler.java

import java.net.*;
import java.io.*;
import java.util.*;

public class tabSeparatedValueHandler extends ContentHandler {

  public Object getContent(URLConnection uc) {
  
    String theLine;
    Vector v = new Vector();
     
    try {  
      DataInputStream dis = new DataInputStream(uc.getInputStream());   
      while ((theLine = dis.readLine()) != null) {
        String[] linearray = lineToArray(theLine);
        v.addElement(linearray);
      }
    }
    catch (IOException e) {
    }
      
    return v;
  
  }

  private String[] lineToArray(String line)  {
  
    StringTokenizer st = new StringTokenizer(line, "\t");
    int numFields = st.countTokens();
    String[] fields = new String[numFields];
    for (int i = 0; i < numFields; i++) {
      fields[i] = st.nextToken();
    }
    
    return fields;
  
  }

}