/** StrList class * This class provides a set of Strings to be used for * drawing the Trie **/ import java.awt.*; import java.io.*; import java.net.*; import java.util.*; public class StrList { private String nodes_array[]; DataInputStream inStream; private int num = 0; public StrList( URL url ) { try { URLConnection urlc = url.openConnection(); inStream = new DataInputStream( urlc.getInputStream() ); num = loadNodes(inStream); } catch( IOException e ) { System.out.println("StrList: URL connection error"); } } private int loadNodes(DataInputStream inStream) { int n_nodes = 0, cnt = 0; String line, item1; System.out.println("Load_Nodes: entry" ); try { // Read the first line of the file //returns the number of elements in the file if ((line = inStream.readLine()) != null) { System.out.println("Load_Nodes: line [" + line + "]" ); StringTokenizer Data = new StringTokenizer(line, " "); item1 = Data.nextToken(); n_nodes = Integer.parseInt( item1 ); System.out.println("instream is "+ n_nodes); nodes_array = new String[n_nodes]; // Read the element supplied for the test // and restore them in the array while(( cnt < n_nodes ) && ((line = inStream.readLine()) != null) ) { System.out.println("Load_Nodes: line [" + line + "]" ); Data = new StringTokenizer(line, " "); item1 = Data.nextToken(); nodes_array[cnt] = item1; cnt++; } } } catch (IOException e) { System.err.println("error in file" +e.toString()); System.exit(1); } return n_nodes; } public String elementAt( int k ) { if ( k < nodes_array.length ) { return nodes_array[k]; } else return null; } public int getDataSize() { return num; } }