跪求一个计数器问题!!!!
javabean:
package ch10;
import java.io.*;
public class FileWRBean
{
private String path;
private String str_written;
private String str_read;
public FileWRBean()
{
}
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path=path;
}
public String getStr_written()
{
return str_written;
}
public void setStr_written(String str_written)
{
this.str_written=str_written;
}
public String getStr_read()
{
return str_read;
}
public void setStr_read(String str_read)
{
this.str_read=str_read;
}
public int ReadFile()
{
try
{
FileReader freader=new FileReader(path);
BufferedReader bfdreader=new BufferedReader(freader);
str_read=bfdreader.readLine();
String str_line=bfdreader.readLine();
while(str_line!=null)
{
str_read=str_read+ " <br> "+str_line;
str_line=bfdreader.readLine();
}
bfdreader.close();
freader.close();
return 0;
}
catch (
IOException e)
{
System.out.println( "文件读取错误! ");
return -1;
}
}
public int WriterOver()
{
try
{
FileWriter fwriter=new FileWriter(path);
BufferedWriter bfwriter=new BufferedWriter(fwriter);
bfwriter.write(str_written,0,str_written.length());
bfwriter.flush();
bfwriter.close();
return 0;
}
catch (IOException e)
{
System.out.println( "文件写入错误! ");
return -1;
}
}
public int WriteAppend()
{
try
{
FileWriter fwriter=new FileWriter(path,true);
BufferedWriter bfwriter=new BufferedWriter(fwriter);
bfwriter.newLine();
bfwriter.write(str_written,0,str_written.length());
bfwriter.flush();
bfwriter.close();
return 0;
}
catch (IOException e)
{
System.out.println( "文件写错误! ");
return -1;
}
}
}
jsp: <%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "
errorPage= " " %>
<jsp:useBean id= "fwrBean " class= "ch10.FileWRBean " scope= "session "/>
<%@ page import= "java.io.* "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 计数器 </title>
</head>