编程开发 > JSP > 文章内容

jsp复习资料(17)

2017-1-20编辑:ljnbset

写入操作
 例子:
        <html>
     <head>
  <title>写入文件</title>
     </head>
     <body>
  <jsp:useBean id="myWriter" scope="page" class="fileTool.writeFile"/>
  <% myWriter.toFile("theday.txt"); %>
  <% myWriter.writeRecord("helloworld\n"); %>
     </body>
 </html>

 writeFile.java
 package fileTool;
        import  java.io.*;
 public class writeFile {
  FileWriter out;
  public void toFile(String filename) {
   File file1=new File(filename);
   out=new FileWriter(file1);
  }
  public void writeRecord(String s) {
   out.write(s);
  }
 }

jsp复习资料(15)

热点推荐

登录注册
触屏版电脑版网站地图