繁体   English   中英

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

[英]Reading from a URL and storing in an ArrayList in 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();
   }
 }

您忘记实例化ArrayList<String>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM