创星网络[分享知识 传递快乐]
标题:
JSP读文件代码
[打印本页]
作者:
luinstein
时间:
2012-12-13 17:26
标题:
JSP读文件代码
<%@ page contentType="text/html; charset=gbk" language="java" import="java.io.*" buffer="64kb" %>
<%
String path_in = "";
String content = "";
path_in = request.getRealPath("/")+"admin"+File.separator+"temp_1.txt";
out.println(path_in);
try
{
BufferedReader in = new BufferedReader (new FileReader(path_in));
String file = "";
String temp = "";
while((temp=in.readLine())!=null)
{
file+=temp;
out.println("writer.println(/""+temp+"/");");
}
in.close();
out.println(file);
out.flush();
}
catch(Exception e)
{
out.println(e);
e.printStackTrace();
}
%>
复制代码
----------
说明:也许你读出来的是未被显示的东西,可以查看网页源代码,完全显示。
欢迎光临 创星网络[分享知识 传递快乐] (http://bbs.cxweb.com.cn/)
Powered by Discuz! X3