从URL读取并存储在JAVA中的ArrayList中

时间:2011-10-07 10:35:59

标签: java

我试图从下面的URL中读取似乎有效但但是当我尝试将其存储在ArrayList中时,它会给我一个错误。关于什么导致错误的想法?

public abstract class ItemList implements ItemListInterface{

private static String inputLine;
private static ArrayList<String> wordArray;

public static void main(String[] args) throws Exception {
    URL wordList = new URL("http://dl.dropbox.com/u/18678304/2011/BSc2/phrases.txt");
    BufferedReader in = new BufferedReader(
            new InputStreamReader(
                    wordList.openStream()));



    while ((inputLine = in.readLine()) != null){
        System.out.println(inputLine);
        wordArray.add(inputLine);
    }
    in.close();
   }
 }

1 个答案:

答案 0 :(得分:6)

您忘记实例化ArrayList<String>