package com.zgml.hdfs;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.Test;
public class HdfsClient {
@Test public void testmkdir() throws URISyntaxException, IOException, InterruptedException { //连接的集群nn地址 URI uri = new URI("hdfs://master:8020"); //创建一个配置文件 Configuration configuration = new Configuration(); //1、获取到了客户端对象 FileSystem fs = FileSystem.get(uri,configuration,"root"); //FileSystem.get(new URI("hdfs://master:9000"),new Configuration()); //2、创建一个文件夹 fs.mkdirs(new Path("/xiyou/huaguoshan")); //3、关闭资源 fs.close(); }
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)