package com.yeqc.testDomo;
import java.io.File;
public class HelloFolder {
public static void main(String[] args) {
File folder = new File("my new folder");
folder.mkdir();
System.out.println("文件夹创建完成");
}
}
package com.yeqc.testDomo;
import java.io.File;
public class HelloFolder {
public static void main(String[] args) {
File folder = new File("my new folder/one/two/three");
if (folder.mkdirs()) {
System.out.println("文件夹创建完成");
}else{
if (folder.exists()) {
System.out.println("文件夹已存在不用创建");
}else{
System.out.println("文件创建失败");
}
}
}
}
package com.yeqc.testDomo;
import java.io.File;
public class HelloFolder {
public static void main(String[] args) {
File folder = new File("my new folder");
File newfolder = new File("my new folder-new");
if (folder.renameTo(newfolder)) {
System.out.println("完成");
}else{
System.out.println("失败");
}
}
}
package com.yeqc.testDomo;
import java.io.File;
public class HelloFolder {
public static void main(String[] args) {
File newfolder = new File("my new folder-new/one/two");
if (newfolder.delete()) {
System.out.println("成功");
}else{
System.out.println("失败");
}
}
}