Home  >  Article  >  Database  >  jsp计数器制作手册_MySQL

jsp计数器制作手册_MySQL

WBOY
WBOYOriginal
2016-06-01 14:07:36994browse

手册计数器

  计数器是一般网站必备的东东,别小看它了,每当站长看着小小计数器上的数字飞速增长的时候,感觉实在是好极了。以前我们用cgi、asp来写计数器,这方面的文章很多了,在这里,我们将会采用目前比较流行的jsp技术演示如何做一个计数器。


returnStr =currentRecord;
}
//返回读取文件的数据
return returnStr;
}
//ReadFile方法用来将数据counter+1后写入到文本文件filePath中
//以实现计数增长的功能
public void WriteFile(String filePath,String counter) throws FileNotFoundException
{
path = filePath;
//将counter转换为int类型并加一
int Writestr = Integer.parseInt(counter)+1;
try {
//创建PrintWriter对象,用于写入数据到文件中
PrintWriter pw = new PrintWriter(new FileOutputStream(filePath));
//用文本格式打印整数Writestr
pw.println(Writestr);
//清除PrintWriter对象
pw.close();
} catch(IOException e) {
//错误处理
System.out.println("写入文件错误"+e.getMessage());
}
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn