I am downloading files from an ftp and I use the following code to write the inputstream (from the ftp) to a file, but the written file differs from the original. Why? What am I doing wrong? The original file is 2,572,288 bytes but the downloaded file is 2,584,941 bytes
System.out.println("Starting download!!!");
boolean downloading = true;
int loaded = 0;
BufferedInputStream inStream = new BufferedInputStream(ftp.retrieveFileStream("godansen.avi"));
fileWriter = new FileOutputStream("c:\\temp\\" + "godansen.avi");
while(downloading){
byte pakke[] = new byte[5];
int byteval = inStream.read(pakke, 0, 5);
if (byteval!=-1){
fileWriter.write(pakke, 0, byteval);
fileWriter.flush();
}else{
downloading = false;
}
loaded += 5;
}