简体   繁体   English

java.io.IOException:过早的EOF

[英]java.io.IOException: Premature EOF

I am trying to download an xml file using Stream and things was fine , until the xml size became bigger than 9 MB , so i've got this error java.io.IOException: Premature EOF 我正在尝试使用Stream下载xml文件,一切都很好,直到xml大小变得大于9 MB为止,所以我遇到了此错误java.io.IOException:过早的EOF

this is the code 这是代码

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;
    }

尝试使用分块流模式。

问题可能是您的应用程序运行得比获取输入数据快

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM