我必须读取包含一行字符串的dict.txt文件,并将这些字符串添加到数组列表中。将InputStream读取到Arraylist
我尝试这样做:
public ArrayList<String> myDict = new ArrayList<String>();
InputStream is = (getResources().openRawResource(R.raw.dict));
BufferedReader r = new BufferedReader(new InputStreamReader(is));
try {
while (r.readLine() != null) {
myDict.add(r.readLine());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但蹊跷的...
你第二次阅读两次同时添加到列表中。 – 2011-12-16 09:14:24