我不知道为什么会出现 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)