本文共 1362 字,大约阅读时间需要 4 分钟。
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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( "文件夹创建完成" ); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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( "文件创建失败" ); } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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( "失败" ); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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( "失败" ); } } } |
转载地址:http://nzszx.baihongyu.com/