开发者

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

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(开发者_JAVA技巧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;
    }


Try using chunked streaming mode.


The problem might be that your application runs faster than it retrieves input data

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜