统计页面的访问量
这个是在本地e盘建一个文件 每次执行的时候读取文件里边的数值,并把数值+1再写入进去
try{
File file = new File("E:/inter/count.txt");
FileReader reader = new FileReader(file);
int fileLen = (int)file.length();
char[] chars = new char[fileLen];
reader.read(chars);
String txt = String.valueOf(chars);
System.out.println(txt);
int i=Integer.parseInt(txt);
i=i+1;
String s=i+"";
File f = new File("E:/inter/count.txt");
if (f.exists()) {
f.delete();
}
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
PrintWriter pw = new PrintWriter(fos);
System.out.print(s);
pw.write(s);
pw.flush();
fos.close();
pw.close();
}catch(Exception e){
}
这个是在本地e盘建一个文件 每次执行的时候读取文件里边的数值,并把数值+1再写入进去
try{
File file = new File("E:/inter/count.txt");
FileReader reader = new FileReader(file);
int fileLen = (int)file.length();
char[] chars = new char[fileLen];
reader.read(chars);
String txt = String.valueOf(chars);
System.out.println(txt);
int i=Integer.parseInt(txt);
i=i+1;
String s=i+"";
File f = new File("E:/inter/count.txt");
if (f.exists()) {
f.delete();
}
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
PrintWriter pw = new PrintWriter(fos);
System.out.print(s);
pw.write(s);
pw.flush();
fos.close();
pw.close();
}catch(Exception e){
}