0
I am trying to download a "zipped" folder through the URL http://portal.insoft4.com.br/site/Download/RepositorioSCR/Teste.zip
(FTP) with the following code snippet made in Java:
try (BufferedInputStream in = new BufferedInputStream(new URL(DOWNLOAD_PATH + fileName + ".zip").openStream());
FileOutputStream fileOutputStream = new FileOutputStream(SAVE_PATH + fileName + ".zip")) {
// byte[] dataBuffer = new byte[1024];
int bytesRead;
while ((bytesRead = in.read()) != -1) {
fileOutputStream.write(bytesRead);
}
} catch (IOException e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionDetails = sw.toString();
log.error(exceptionDetails);
updateStatusToError();
}
But when trying to extract the downloaded file, the following error is reported:
Can anyone explain why the file is corrupted and of different size?
What would be the correct way to download a folder compressed with other files (photos, files .jar
and .ini
) within?