1 2 1

eclipse — 在HDFS上创建目录(2)

  1 public class HDFSClient {
  2 
  3 	public static void main(String[] args) throws IOException, Exception, URISyntaxException {
  4 		//操作集群
  5 		//获取文件系统
  6 		Configuration conf = new Configuration();
  7 
  8 		//获取HDFS客户端对象
  9 //		FileSystem fs = FileSystem.get(conf);
 10 		FileSystem fs = FileSystem.get(new URI("hdfs://192.168.12.161:9000"), conf, "hadoop");
 11 
 12 		//在hdfs上创建路径
 13 		fs.mkdirs(new Path("/0200/asd"));
 14 		//关闭资源(释放资源)
 15 		fs.close();
 16 		//验证程序是否结束
 17 		System.out.println("over");
 18 	}
 19 
 20 }
posted @ 2019-09-29 11:23  NotFound-404  阅读(316)  评论(0)    收藏  举报