hadoop创建目录
package com.hadoop.hdfs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import java.io.IOException; public class Client { public static void main(String[] args) throws IOException { Configuration conf=new Configuration(); conf.set("fs.defaultFS","hdfs://localhost:9000"); //修改用户方法 //1.vm arguments中添加后面的参数来修改用户 -DHADOOP_USER_NAME=hadoop //2. conf.set使用重载方法修改用户 //1.获取hdfs客户端对象 FileSystem fs=FileSystem.get(conf); //2.在hdfs上创建路径 fs.mkdirs(new Path("/hadoop/example/xy1")); //3.关闭资源 fs.close(); System.out.println("over"); } }
相关推荐
WeiHHH 2020-09-23
tomli 2020-07-26
eternityzzy 2020-07-19
飞鸿踏雪0 2020-07-09
swazerz 2020-06-22
ViMan0 2020-06-21
zzjmay 2020-06-08
sujins 2020-06-05
strongyoung 2020-06-01
sujins 2020-05-30
sujins 2020-05-29
archive 2020-05-28
changjiang 2020-11-16
minerd 2020-10-28
Aleks 2020-08-19
WeiHHH 2020-08-17
飞鸿踏雪0 2020-07-26