2000下测试通过,没有异常提示吗?2003没用过,权限问题可能性不大,可试用administrator登陆运行。最后一招加上out.close();

解决方案 »

  1.   

    代码没有错。流操作完毕后最好加上out.close().
    我相信文件已经在你的硬盘上生成(在你电脑的系统目录下)
    为方便查看文件,你可以指定路径名。如:File f=new File("E://test.txt");
      

  2.   

    package java3;
    import java.io.*;
    public class WriteFileExample
    {
    public static void main(String[] args) 
    {
    try
    {
    File aFile=new File("WriteExample.txt"); //指定文件名
    //建立输出流
    FileOutputStream out= new FileOutputStream(aFile); byte[] b=new byte[1024];
    String str="This is a test file";
    b=str.getBytes(); //进行String到byte[]的转化
    out.write(b); //写入文本内容
    }
    catch (IOException e)
    {
    System.out.println(e.toString());
    }
    }
    }代码没错误
      

  3.   

    在out.write(b)后加上out.close()以关闭输出流