[英]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.