java的file创建文件/夹


import java.io.File;
import java.io.IOException;

public class FileDemo2 {
    public static void main(String[] args) throws IOException {
        //1.创建文件
        File file = new File("E:\\Workpace\\java.txt");
        System.out.println(file.createNewFile());
        //2.创建文件夹
        File file1 = new File("E:\\Workpace\\java");
        System.out.println(file1.mkdir());
        //3.创建多级文件夹
        File file2 = new File("E:\\Workpace\\javaweb\\Html");
        System.out.println(file2.mkdirs());
    }
}

posted @ 2021-04-30 22:54  code-G  阅读(490)  评论(0编辑  收藏  举报