PrintWriter writer = new PrintWriter(new FileOutputStream("c:/myword.txt"), true);

解决方案 »

  1.   

    File file=new File("C:\\Documents and Settings\\Administrator.QING\\桌面\\wenjian1.txt");
      

  2.   

    C:\Documents and Settings\Administrator.QING\桌面\wenjian1.txt该目录中包含了"非法"字符,换一个只有英文的目录就可以了,试试看把
      

  3.   

    如果你的程序是在Windows操作系统下建立文件那么你的文件名应该这样写:
    File file = new File("C:\\Documents and Settings\\Administrator.QING\\桌面\\wenjian1.txt");
    另外,最好不要用中文的路径;
    还有建立文件的时候最好捕捉下面几个异常:
    FileNotFoundException和IOException
      

  4.   

    character "\" is special in java,it should be used as such:
    String s = "He said:\"I am a Student.\"";
    and if you want to use "\" you must write "\\" .
      

  5.   

    character "\" is special in java,it should be used as such:
    String s = "He said:\"I am a Student.\"";
    and if you want to use "\" you must write "\\" .或者用/也可以
      

  6.   

    File file=new File("C:\Documents and Settings\Administrator.QING\桌面\wenjian1.txt");
    改成File file=new File("C:/Documents and Settings/Administrator.QING/桌面/wenjian1.txt");
      

  7.   

    java文件好像不能放在中文目录里面,就是路径中不能有中文,建议改文件架!