有没有最简单的计数器啊,希望大侠给个

kuflash8 2003-10-17 11:19:07
有没有最简单的计数器啊,希望大侠给个
...全文
22 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
storejyjs 2003-11-25
  • 打赏
  • 举报
回复
<html>
<body>
<%@ page import="java.io.*"%>
<%
BufferedReader file;
String countFile="c:\\count.txt";

String readStr=null;
int writeStr=1;
try
{
file=new BufferedReader(new FileReader(countFile));
readStr=file.readLine();
}catch(IOException e)
{
System.out.println("read data error");
}
if(readStr==null) readStr="no data";
else
{
writeStr=Integer.parseInt(readStr)+1;
}

try{
PrintWriter pw;
pw=new PrintWriter(new FileOutputStream(countFile));
pw.println(writeStr);
pw.close();
} catch(IOException e)
{
System.out.println(e.getMessage());
}
%>
<h1> you are the </h1>
<h3> <%=readStr%></h3>
<h1> vistor to the page</h1>
</body>
</html>

huguangwu 2003-10-17
  • 打赏
  • 举报
回复
结合数据库或者写文件的方式,自己写一个啊
jackal81 2003-10-17
  • 打赏
  • 举报
回复
www.java-cn.com
自己下一个

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧