file_write.jsp

来自「jakarta-taglibs」· JSP 代码 · 共 45 行

JSP
45
字号
<%@taglib uri="http://jakarta.apache.org/taglibs/io-1.0" prefix="io" %>
<%@page import="java.io.*"%>
<%--
  
  Serves up a HTTP request (the Jakarta home page) i.e. a proxy

--%>
<html>
<body>
<h1>File Write demo</h1>

<h2>Create a temporary file</h2>

<%
    File file = File.createTempFile( "jakarta-home-", ".html" );
    FileWriter fileWriter = new FileWriter( file );
%>

<p>
    This sample will write the Jakarta home page to a temporary file at: 
</p>
<p>
    <b><%= file.getCanonicalPath() %></b>
</p>

<io:pipe writer="<%= fileWriter %>">
    <io:http url="http://jakarta.apache.org/index.html"/>
</io:pipe>
<%
    fileWriter.close();
%>

<p>
    Done. File is:         
    <b><%= file.length() %></b> bytes long
</p>

<h2>Now lets read it...</h2>

<io:body reader="<%= new FileReader( file ) %>"/>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?