📜  java读取文件上的所有对象-TypeScript代码示例

📅  最后修改于: 2022-03-11 14:48:27.956000             🧑  作者: 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());
  }
}