【发布时间】:2013-03-08 14:12:09
【问题描述】:
这里是得到 NullPointerException 错误的代码:
InputStream is = getAssets().open("twentyone.txt");
InputStreamReader iz=new InputStreamReader(is);
BufferedReader br = new BufferedReader(iz);
可能出了什么问题?
*编辑:printStackTrace
03-19 18:20:18.662: E/AndroidRuntime(929): Caused by: java.lang.NullPointerException
编辑 2:代码直到异常:
public class ListViewAa3 extends ListViewA{
public String[] process(String cti)throws IOException{
String ctid=cti;
Log.d("Outside try invoked","tag1");
try{
Log.d("beginning of try invoked","tag2");
try{
InputStream is = getAssets().open("USCOUNTIES.txt");
InputStreamReader iz=new InputStreamReader(is);
BufferedReader br = new BufferedReader(iz);}catch(Exception e){e.printStackTrace();}
【问题讨论】:
-
getAssets()可能为空 -
如何解决?我的资产文件夹有上述文件..
-
很难说没有看到更多代码,但首先通过使用调试器或查看堆栈跟踪来确定
getAssets()是否确实为空。然后找出它为什么为空。 -
请给出完整代码
-
你的 getAssets() 是什么?检查它是否为空
标签: java android nullpointerexception inputstream