我得到了EOFException,我不知道为什么?我尝试了很多方法来解决这个问题,并修改了代码和目录,但没有解决。
try {
DataInputStream read = new DataInputStream(new FileInputStream("accounts.bin"));
while (read.available() > 0) {
int accNum = read.readInt();
String accName = read.readUTF();
String accType = read.readUTF();
double balance = read.readDouble();
System.out.println(accNum + " " + accName + " " + accType + " " + balance);
}
} catch (IOException e ) {
System.out.println("File not found");
e.printStackTrace();
}
}
}