• Post Reply Bookmark Topic Watch Topic
  • New Topic

File Download problem with word/excel ?? only

 
yo nara
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
i have written the code , fairly as below for file download
String filename = "C:\\a.xls";
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename="+filename);
ServletOutputStream out1 = response.getOutputStream();
File fileToDownload = new File(filename);
FileInputStream fileInputStream = new FileInputStream(fileToDownload);
int i;
while ((i=fileInputStream.read())!=-1)
{
out1.write(i);
}
fileInputStream.close();
out1.flush();
out1.close();
}catch(Exception e) // file IO errors
{
e.printStackTrace();
}
a.xls contains japanese characters .i am unable to see the contents of the file downloaded.all the characters get disrupted
can anyone suggest me the solution?
i have tried with different java.io classes also .
uptil now i am able to see the txt files and pdf files clearly but if i try to download word or excel files i am unable to see the contents.

thnx in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!