欢迎光临
我们一直在努力

在JSP中写text文件-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

作者: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 %>">

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在JSP中写text文件-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章