Java Mysterious EOF exception with readObject
问题 The following code produces an EOFException . Why is that? public static Info readInfoDataFromFile(Context context) { Info InfoData = null; FileInputStream fis = null; ObjectInputStream ois = null; Object object = null; if (context.getFileStreamPath("InfoFile.dat").exists()) { try { fis = context.openFileInput("InfoFile.dat"); ois = new ObjectInputStream(fis); Object temp; try { // here it throws EOF exception in while loop while ((temp = ois.readObject()) != null) { object = temp; } } catch