import java.io.File;
import java.io.IOException;
public class Admin {
public static void main(String... args) {
String path0 = ".\\aa";
String path1 = ".\\aakkk.java";
File f = new File(path0);
// 创建文件夹
if (!f.exists()) {
f.mkdirs();
}
f = new File(path1);
// 创建文件
if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.IOException;
public class Admin {
public static void main(String... args) {
String path0 = ".\\aa";
String path1 = ".\\aakkk.java";
File f = new File(path0);
// 创建文件夹
if (!f.exists()) {
f.mkdirs();
}
f = new File(path1);
// 创建文件
if (!f.exists()) {
try {
f.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
2:
import java.io.File ;
import java.io.IOException ;
public class FileDemo{
public static void main(String args[]){
File f = new File(".\\"+File.separator+"photo") ;// 实例化File类的对象
f.mkdir() ;
// 创建文件夹
System.out.println("创建成功");
}
};