作者:blueski编译
使用printwriter对象即可写text文件。
请参考以下示例:
<%@ page import="java.io.*" %>
<%
string str = "print me";
//always give the path from root. this way it almost always works.
string nameoftextfile = "/usr/anil/imp.txt";
try {
printwriter pw = new printwriter(new fileoutputstream(nameoftextfile));
pw.println(str);
//clean up
pw.close();
} catch(ioexception e) {
out.println(e.getmessage());
}
%>
现在,打开imp.txt加以查看,字符串"print me"应该已经写入。
还有另一种方法,使用in16标记库的file tag,可参考http://sourceforge.net/project/?group_id=1282.
其示例的语法为:
<ext:file action="write|append|create|copy|move|delete|rename|read" from="<%= myfilename %>">
