java.io.IOException: Premature EOF

Posted by jouzef19 on Stack Overflow See other posts from Stack Overflow or by jouzef19
Published on 2010-05-02T16:48:33Z Indexed on 2010/05/03 0:27 UTC
Read the original article Hit count: 442

Filed under:

Hi: 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(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;
    }

thanks in advanced

© Stack Overflow or respective owner

Related posts about java