Struts 2 完成直接输出流到浏览器
?
????????????
??????????? OutputStream os = response.getOutputStream();
????????????
??????????? in = new FileInputStream(file);
??????????? int tp = in.read();
??????????? while (tp != -1) {
??????????????? response.getOutputStream().write(tp);
??????????????? tp = in.read();
??????????? }
??????????? os.flush();
??????? } catch (Throwable e) {
??????????? logger.info("文件下载失败!", e);
??????????? throw new RuntimeException("文件下载失败!", e);
??????? } finally {
??????????? try {
??????????????? in.close();
??????????? } catch (IOException e) {
??????????????? logger.info("关闭流失败!", e);
??????????????? throw new RuntimeException("关闭流失败!", e);
??????????? }
??????? }
?