public static void main(String[] args) throws IOException {
//demo1();
File dir1 = new File("aaa");
System.out.println(dir1.mkdir());
File dir2 = new File("bbb.txt"); //这样写是可以的,文件夹也是可以有后缀的
System.out.println(dir2.mkdir());
File dir3 = new File("ccc\\ddd");
System.out.println(dir3.mkdirs()); //创建多级目录
}
public static void demo1() throws IOException {
File file = new File("yyy.txt");
System.out.println(file.createNewFile()); //如果没有就创建,返回true
File file2 = new File("zzz");
System.out.println(file2.createNewFile());
}
}
|
|