java自动创建文件路径

来源:互联网 发布:威尔软件怎么样 编辑:程序博客网 时间:2024/04/29 17:59

String path ="d://upload_test_test//file"; //设置一个默认文件夹路径
        File uploadFilePath = new File(path);
        // 如果该目录不存在,则创建之
        if(uploadFilePath.exists() == false) {
        uploadFilePath.mkdirs();
        System.out.println("路径不存在,但是已经成功创建了" + path);
        }else{
        System.out.println("文件路径存在" + path);
        }

原创粉丝点击