
我想把ArrayList存到txt上,然后在读出来,为啥读出来的对象都没数据啊

public void saveData() {
// TODO 自动生成的方法存根
File file = new File("D:\\tank.txt");
FileOutputStream out;
try {
out = new FileOutputStream(file);
ObjectOutputStream tankOut = new ObjectOutputStream(out);
tankOut.writeObject(ScenceData.tankList);
tankOut.flush();
tankOut.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void readData() {
File file = new File("D:\\tank.txt");
FileInputStream in;
try {
in = new FileInputStream(file);
ObjectInputStream tankIn = new ObjectInputStream(in);
Object obj = tankIn.readObject();
ScenceData.tankList = (ArrayList)obj;
tankIn.close();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}