Hello
I've a strange problem.
I displaying a directory listing to the user. The user selects a file to be downloaded. The files are of diff formats - txt, csv, xls, pdf, zip
The download works for pdf, txt but for XLS, when I save the file, its has junk.
Any pointer ???
----------------Attached source. It is part of
JSP not a
servlet String _fileLocation = "C:/test.xls";
String _fileName = "ttt.XLS";
String _fileType = "application/vnd.ms-excel";
BufferedInputStream bufferedInputStream = null;
File inputFile = new java.io.File(_fileLocation);
int fileSize = (int) inputFile.length();
System.out.println("fileLocation");
System.out.println(_fileLocation);
System.out.println("fileSize");
System.out.println(fileSize);
if (fileSize > 0)
{
FileInputStream fis = new FileInputStream(inputFile);
bufferedInputStream =
new BufferedInputStream(new FileInputStream(inputFile));
byte[] fByte = new byte[fileSize];
if (fis.read(fByte, 0, fileSize) >= 0)
{
//Committing the
response.setContentType(_fileType);
//response.setContentLength(fByte.length);
response.setHeader(
"Content-Disposition",
"attachment; filename="+ _fileName);
response.getOutputStream().write(fByte);
response.getOutputStream().flush();
response.getOutputStream().close();
}
fis.close();
}
else
{
System.out.println("The report file is empty");
}
-----------------------
Thanks for help
[ December 03, 2003: Message edited by: Jax Desi ]