在JAVA中读取URL并存储在ArrayList中
我正在尝试从下面的URL中读取,这似乎有效,但当我尝试将其存储在ArrayList中时,它会给我一个错误。你知道是什么导致了这个错误吗在JAVA中读取URL并存储在ArrayList中,java,Java,我正在尝试从下面的URL中读取,这似乎有效,但当我尝试将其存储在ArrayList中时,它会给我一个错误。你知道是什么导致了这个错误吗 public abstract class ItemList implements ItemListInterface{ private static String inputLine; private static ArrayList<String> wordArray; public static void main(String[] arg
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();
}
}
公共抽象类ItemList实现ItemListInterface{
私有静态字符串输入线;
私有静态数组列表字数组;
公共静态void main(字符串[]args)引发异常{
URL wordList=新URL(“http://dl.dropbox.com/u/18678304/2011/BSc2/phrases.txt");
BufferedReader in=新的BufferedReader(
新的InputStreamReader(
openStream());
而((inputLine=in.readLine())!=null){
系统输出打印LN(输入线);
添加(inputLine);
}
in.close();
}
}
您忘记实例化ArrayList
您忘记实例化ArrayList
存储时收到的错误消息是什么?ie.wit.bsc2.autosuggest.ItemList.main(ItemList.java:24)的线程“main”java.lang.NullPointerException中的aaa异常存储时收到什么错误消息?ie.wit.bsc2.autosuggest.ItemList.main(ItemList.java:24)处线程“main”java.lang.NullPointerException中的aaa异常