思路:
1、创建目录文件对象 File file = new File()
2、判断目录是否存在 !file.exists()
3、不存在则创建文件 file.mkdirs()
import java.io.File;
/*
* Java快速创建多级目录
*/
public class MyContant {
public static void main(String[] args) {
// 本地路径没有,这创建本地工作任务基础路径
String pathname = "F:/user/company/mapreduce";
File file = new File(pathname);
boolean flag = false;
if(!file.exists()) {
flag = file.mkdirs();
}
System.out.println("path status:"+flag);
}
}
编写MapReduce需要固定输入输出路径,项目打包到线上服务前最好在本地先测试一遍
目录是多级的,很长,一个个创建特别麻烦,用Java创建比较高效(偷懒成功!)!
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有