我需要帮助从序列化文本文件中读取数组列表,我不相信我有问题但是我看不到它是否实际上存储了所有信息,因为我无法打印出来进行测试,这里是代码片段:当我从文件中读取时,我得到的 ArrayList 无法转换为 StoreAddress
FileInputStream ios = new FileInputStream("C:\\Users\\Mr Cata\\Desktop\\Testingoutput.txt");
ObjectInputStream ois = new ObjectInputStream(ios);
StoreAddress SAR = (StoreAddress)ois.readObject();
ArrayList<StoreAddress> ALStore = (ArrayList)ois.readObject();
for(int i = 0; i < ALStore.size(); i++){
String list = ALStore.get(i).toString();
}
ios.close();
下一个
for(int i = 0; i < ALStore.size(); i++){
ALStore.get(i);
}
...
for(int i = 0; i < ALStore.size(); i++){
if (i >= ALStore.size())
{
ALStore.add(SA);}
}
FileOutputStream fos = new FileOutputStream("C:\\Users\\Mr Cata\\Desktop\\Testingoutput.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(ALStore);
fos.close();
}