import java.io.*;
import java.net.*;


public class wordList  {
    URL docURL;
    InputStream rawFile;
    DataInputStream dataFile;
    static String str;
    static int numWords;
    static String wordList[];

    public wordList(URL fileURL, String fileName) {
      docURL = fileURL;
      try
      {
         rawFile = (new URL(docURL, fileName)).openStream();
         dataFile = new DataInputStream(rawFile);
      }
      catch (IOException e)
      {
         e.printStackTrace();
      }
      loadWord();
   }



   void loadWord() {
        String tempStr;
        try {
            tempStr = dataFile.readLine();
            numWords = (new Integer(tempStr)).intValue();
            wordList = new String[numWords];

            for (int x = 0; x < numWords; x++) {
                tempStr = dataFile.readLine();
                wordList[x] = tempStr;
            }
        }
        catch (IOException e)
             e.printStackTrace();
   }


    public static String getWord() {
        return (str = wordList[(int)(Math.round(Math.random() * numWords)) + 1]);
    }
}

