为什么,没人帮我呀,为什么呀

解决方案 »

  1.   

    你这个到底有什么问题?
      

  2.   

    <%@ page contentType="text/html; charset=gb2312"%>
    <%@ page import="java.io.*"%>
    <html>
    <head>
    <title>JSP网页记数器</title>
    </head>
    <body>
    <%
    BufferedReader test; //BufferedReader对象,读取文件数据
    String tmp=null; //文本文件中存储的值
    int i=0; //记数值
    String path=request.getRealPath(""); //获取URL

    File f=new File(path,"count.txt"); //获取 File对象
    test=new BufferedReader(new FileReader(f));

    try{
    tmp=test.readLine();
    }catch(FileNotFoundException e){
    e.printStackTrace();
    }

    if(tmp==null){ //第一次运行时
    i=0;
    }
    else{
    i=(int)(Integer.parseInt(tmp)+1);
    }

    //*********************

    try{
    PrintWriter outf=new PrintWriter(new FileOutputStream(f));
    outf.println(i); //将i写入文件中
    outf.close();
    }
    catch(FileNotFoundException e) {
    e.printStackTrace();
    }
    test.close();
    %>
    <p align="center">您是第<%=i%>位访客</p>
    </body>
    </html>我是用了一个File对象的FileReader(File f)
    FileReader(String s)好像不可以老是提示找不到文件
      

  3.   

    各位高手,还有其什么方法么
    为什么会找不到文件呢?