import java.io.StreamTokenizer; import java.io.*; import java.util.Hashtable; import java.net.URL; public class Parser { Hashtable ht; Hashtable aht; public void start() { ht = new Hashtable(30); aht = new Hashtable(70); // open file try { URL inputFile = new URL("http://acg.media.mit.edu/mas962/ps1/code.txt"); StreamTokenizer st = new StreamTokenizer(inputFile.openStream()); int ttt = st.nextToken(); st.toString(); String key = st.sval; ttt = st.nextToken(); st.toString(); String object = st.sval; System.err.println(key+" : "+object); // get first pair while(ttt != st.TT_EOF){ ht.put(key, object); // get next pair ttt = st.nextToken(); st.toString(); key = st.sval; ttt = st.nextToken(); st.toString(); object = st.sval; System.err.println(key+" : "+object); } String foo = new String("0"); ht.put(foo, foo); foo = new String("1"); ht.put(foo, foo); foo = new String("2"); ht.put(foo, foo); foo = new String("3"); ht.put(foo, foo); foo = new String("4"); ht.put(foo, foo); foo = new String("5"); ht.put(foo, foo); foo = new String("6"); ht.put(foo, foo); foo = new String("7"); ht.put(foo, foo); foo = new String("8"); ht.put(foo, foo); foo = new String("9"); ht.put(foo, foo); } catch (Exception e) { System.err.println("mari ex!: " + e); } } public String parse(String key) { String obj = (String)ht.get(key); return obj; } }