JSP读取包含汉字的文本文件
JSP读取包含汉字的文本文件
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.io.*"%>
<%
File file = new File(request.getRealPath("/painting/advert/01/index.txt"));// 指定要读取的文件
InputStreamReader isr =null;
isr = new InputStreamReader(new FileInputStream(file),"utf-8");
BufferedReader br = null;
br = new BufferedReader(isr);
String str = null;
while((str=br.readLine())!=null){
out.print(str);
}
br.close();
%>