[英]Reading from a URL and storing in an ArrayList in JAVA
I'm trying to read from the URL below which appears to work but when I try to store it in the ArrayList it gives me an error. 我正在尝试从下面的似乎有效的URL进行读取,但是当我尝试将其存储在ArrayList中时,它给我一个错误。 Any ideas on whats causing the error?
关于导致错误的原因有什么想法?
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.