Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Incomplete file download

843842Jun 26 2008 — edited Jun 26 2008
I 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);

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2008
Added on Jun 26 2008
4 comments
238 views