G
Girish T Deshpande
I am using Tomcat 4 and wish to download binary file(actualy an excel
and pdf file) to the local disk.
Since out.write ouputs the character array, I get error message when I
pass byte array.
The part of the code is below(I have set proper mime type)
FileReader f = new FileReader("C:/Tengli/jakarta-tomcat-4.1.24/webapps/ROOT/JavaExcel/ouput9.xls");
BufferedInputStream inputStream = new BufferedInputStream(new
FileInputStream("C:/Tengli/jakarta-tomcat-4.1.24/webapps/ROOT/JavaExcel/ouput9.xls"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int nBytes = inputStream.read(buffer);
if (nBytes < 0) break;
out.write(buffer, 0, nBytes);
}
//buffer = out.toByteArray();
I also get the error that out is already defined in
_jspService(......).
If I use other variable name instead of out it compiles and runs fine
but the file will be completely empty since it writes at unknown
place.
Could anyone give the entire code!
Thank you
and pdf file) to the local disk.
Since out.write ouputs the character array, I get error message when I
pass byte array.
The part of the code is below(I have set proper mime type)
FileReader f = new FileReader("C:/Tengli/jakarta-tomcat-4.1.24/webapps/ROOT/JavaExcel/ouput9.xls");
BufferedInputStream inputStream = new BufferedInputStream(new
FileInputStream("C:/Tengli/jakarta-tomcat-4.1.24/webapps/ROOT/JavaExcel/ouput9.xls"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int nBytes = inputStream.read(buffer);
if (nBytes < 0) break;
out.write(buffer, 0, nBytes);
}
//buffer = out.toByteArray();
I also get the error that out is already defined in
_jspService(......).
If I use other variable name instead of out it compiles and runs fine
but the file will be completely empty since it writes at unknown
place.
Could anyone give the entire code!
Thank you