您的位置:首页 > 运维架构 > Linux

Linux下的文本统计命令之wc命令详解

2014-09-23 15:02 513 查看
查看复制到剪切板打印

<%@ page session="false" pageEncoding="UTF-8"%>   

<%@page import="java.io.*"%>   

<%   

  response.setContentType("application/pdf");   

  

  out.clearBuffer(); // 如果使用JSP,需要加上这一句     

  OutputStream os = response.getOutputStream(); // 页面输出流,jsp/servlet都可以     

  response.addHeader("Content-Disposition", new String(("filename=pattern.pdf")   

      .getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名     

  File f = new File(application.getRealPath(".")+"/pattern.pdf"); // 你的文件     

  InputStream is = new FileInputStream(f); // 文件输入流     

  byte[] bs = new byte[1024]; // 读取缓冲区     

  int len;   

  while ((len = is.read(bs)) != -1) { // 循环读取     

    os.write(bs, 0, len); // 写入到输出流     

  }   

  is.close(); // 关闭     

  os.close(); // 关闭   

%>  

<%@ page session="false" pageEncoding="UTF-8"%>
<%@page import="java.io.*"%>
<%
response.setContentType("application/pdf");

out.clearBuffer(); // 如果使用JSP,需要加上这一句
OutputStream os = response.getOutputStream(); // 页面输出流,jsp/servlet都可以
response.addHeader("Content-Disposition", new String(("filename=pattern.pdf")
.getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名
File f = new File(application.getRealPath(".")+"/pattern.pdf"); // 你的文件
InputStream is = new FileInputStream(f); // 文件输入流
byte[] bs = new byte[1024]; // 读取缓冲区
int len;
while ((len = is.read(bs)) != -1) { // 循环读取
os.write(bs, 0, len); // 写入到输出流
}
is.close(); // 关闭
os.close(); // 关闭
%>


请注意这一句

查看复制到剪切板打印

response.addHeader("Content-Disposition", new String(("filename=pattern.pdf")   

      .getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名    

response.addHeader("Content-Disposition", new String(("filename=pattern.pdf")
.getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名

如果要下载的话,就改成


查看复制到剪切板打印

response.addHeader("Content-Disposition", new String(("attachment; filename=pattern.pdf")   

      .getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名    

response.addHeader("Content-Disposition", new String(("attachment; filename=pattern.pdf")
.getBytes("GBK"), "ISO-8859-1")); // 针对中文文件名


这个东西在http协议里面有规定。

顺便说一句,filename是你下载或者另存为时的文件名,必须用iso-8859-1的编码才可以。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: