excel « Excel « JSP-Servlet Q&A





1. facing problem in writing Excel Doc bytes into ServletOutputStream    coderanch.com

BufferedInputStream in = null; OutputStream sos = null; byte[] buffer = new byte[1024]; int r = 0; try { in = new BufferedInputStream(new FileInputStream(new File("/path/to/the/file"))); sos = response.getOutputStream(); while ((r = in.read(buffer, 0, buffer.length)) != -1) { sos.write(buffer, 0, r); } sos.flush(); } finally { if(in != null) in.close(); if(sos != null) sos.close(); }