ServletOutputStream out = appContext.getResponse()
.getOutputStream();
appContext.getResponse().setContentType("application/excel");
appContext.getResponse().setHeader("Content-disposition",
"attachment; " + "filename=temp.xls");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
FileInputStream fin = new FileInputStream(
fileName);
bis = new BufferedInputStream(fin);
bos = new BufferedOutputStream(out);
byte buff[] = new byte[2048 * 8];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length)))
bos.write(buff, 0, bytesRead);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}