【发布时间】:2013-07-10 07:15:57
【问题描述】:
我不知道为什么会出现 java.io.EOFException。从服务器获取二进制流后,我想写一个文件。
这是我的代码
inputStream = new DataInputStream(new BufferedInputStream(connection.getInputStream()));
FileOutputStream fos = new FileOutputStream("D:/Apendo API resumable download.txt");
byte b = inputStream.readByte();
while(b != -1){
fos.write(b);
b = inputStream.readByte();
}
fos.close();
堆栈跟踪
java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at HttpRequestJSON.JSONRequest.sendRequest(JSONRequest.java:64)
at HttpRequestJSON.Main.main(Main.java:56)
【问题讨论】:
-
您在哪一行得到了异常?
-
当 b = inputStream.readByte();在 while(b != -1)
-
Err,实际上是在尝试读取文件时。
标签: java file io eofexception