gpt4 book ai didi

java.io.IOException : Premature EOF

转载 作者:行者123 更新时间:2023-12-01 16:05:16 24 4
gpt4 key购买 nike

我正在尝试使用 Stream 下载 xml 文件,一切都很好,直到 xml 大小变得大于 9 MB,所以我收到此错误java.io.IOException:过早的 EOF

这是代码

BufferedInputStream bfi = null;
try {
bfi = new BufferedInputStream(new URL("The URL").openStream());
String name = "name.xml";
FileOutputStream fb = new FileOutputStream(name);
BufferedOutputStream bout = new BufferedOutputStream(fb, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x = bfi.read(data, 0, 1024)) >= 0) {
bout.write(data, 0, x);
}
this.deletePhishTankDatabase(this.recreateFileName());
ptda.insertDownloadTime(hour, day, month, year);
bout.close();
bfi.close();
} catch (IOException ex) {
Logger.getLogger(PhishTankDataBase.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
bfi.close();
} catch (IOException ex) {
Logger.getLogger(PhishTankDataBase.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else {
System.out.println("You can't do anything");
return;
}

最佳答案

尝试使用分块流模式。

关于java.io.IOException : Premature EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2754158/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com