java.io.IOException: Premature EOF
- by jouzef19
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