FileWriter file=new FileWriter(path,true);
-->
File file=new File(path);

解决方案 »

  1.   

    try
    {
    String path="gbook.txt";
    PrintWriter pwout = new PrintWriter(new FileOutputStream(path));
    pwout.println(getStr(Line1));
    pwout.println(getStr(Line2));
    pwout.println(getStr(Line3));
    pwout.println(getStr(Line4));
    pwout.println("HR");
    //关闭printwriter对象 
    pwout.close();
    }
    catch(IOException e)
    {
    out.println(e.toString());
    }
      

  2.   

    那就是你的路径问题了!
    String path = request.getRealPath("\\gbook.txt");
    gbook.txt就放在根目录下
      

  3.   

    楼上的,我gbook.txt就放在发布目录啊,但他是空的,没问题吧?好象写不进去,写进去的都是空格
      

  4.   

    pwout.println("HR");
    只写一个试试!
    看有没有什么意外!