import java.io.*;
class FileTest
{
public static void main(String[] args)throws IOException
{
method_2();
}
//演示创建文件
public static void method_2()throws IOException
{
File f1=new File("c:\\s.txt");//为什么目录是C盘运行时出现以下错误呢?
/*
Exception in thread "main" java.io.IOException: 拒绝访问。
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at FileTest.method_2(FileTest.java:52)
at FileTest.main(FileTest.java:45)
*/
boolean b=f1.createNewFile();
System.out.println(b);
}
} |
|