我已经使用serialastion将arrayList保存到二进制文件中。我现在如何从二进制文件中检索这些数据?如何从Java中的二进制文件反序列化数据的ArrayList?
这是我用过的系列化
public void createSerialisable() throws IOException
{
FileOutputStream fileOut = new FileOutputStream("theBkup.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(allDeps);
options();
}
的代码,这个我想使用ArrayList中的反序列化的代码:
public void readInSerialisable() throws IOException
{
FileInputStream fileIn = new FileInputStream("theBKup.ser");
ObjectInputStream in = new ObjectInputStream(fileIn);
try
{
ArrayList readob = (ArrayList)oi.readObject();
allDeps = (ArrayList) in.readObject();
}
catch (IOException exc)
{
System.out.println("didnt work");
}
}
allDeps在声明数组列表类构造器。我试图从文件中保存arrayList到这个类中声明的arrayList。
什么是数组列表? –
有部门名称和地址 – Binyomin
什么是'oi'? –