关于向硬盘写入文件的!
下面应该可向硬盘当前目录下写入一个txt文件,代码应该没错,我机器是2003 fat分区格式,应该不存在权限不足的问题吧???
可怎么就是生成不了文件呢????
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());
}
}
}