我已經使用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'? –