-1
我想读这个名单和电话号码列表中,但该程序不断抛出nullpointerexception。它为什么这样做?空指针异常与objectinputstream
int i=0;
Datab[] b = null;
//b = null;
// The name of the file to open.
String fileName = "datt.dat";
try {
// Use this for reading the data.
byte[] buffer = new byte[1000];
FileInputStream FileIS = new FileInputStream("datt.dat");
ObjectInputStream input = new ObjectInputStream(FileIS);
for(i=0; i<b.length; i++)
b[i]=(Datab)input.readObject();
input.close();
它在哪里把它的异常?哪条线? – 2015-04-01 14:25:43
请提供异常堆栈跟踪。你的代码的附注:你正在用文件名定义一个变量..只是为了再次使用同一个字符串(而不是使用你在try块前面声明的字符串变量。 – GhostCat 2015-04-01 14:26:18