-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