📜  在 java 中从文件中读取多个对象 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:20.401000             🧑  作者: Mango

代码示例1
FileInputStream fis = new FileInputStream("outputFile");
ArrayList objectsList = new ArrayList<>();
boolean cont = true;
while (cont) {
  try (ObjectInputStream input = new ObjectInputStream(fis)) {
    Object obj = input.readObject();
    if (obj != null) {
      objectsList.add(obj);
    } else {
      cont = false;
    }
  } catch (Exception e) {
    // System.out.println(e.printStackTrace());
  }
}