Incomplete file download
843842Jun 26 2008 — edited Jun 26 2008I have a servlet to download files from the server . It downloads the file but swallows a few bytes . 0.5 to 2 bytes sometimes.
And when I compare the files, I find that the last few lines are missing.
Here's what I am doing?Any idea why this is happening
String fileChosen = request.getParameter("paramName");
String fName = System.getProperty("jboss.home.dir")+ File.separator +"server" File.separator "default" File.separator "log" File.separator "default" File.separator fileChosen;
response.setContentType("APPLICATION/OCTET-STREAM");
String disHeader = "attachment;filename=" +fileChosen;
response.setHeader("Content-Disposition",disHeader);
File fileToDownload = new File(fName);
fileInputStream = new
FileInputStream(fileToDownload);
input = new BufferedInputStream(fileInputStream);
out = new BufferedOutputStream(response.getOutputStream());
int i;
while ((i = input.read())!=-1)
{
out.write(i);
}