1)创建Configuration2)获取FileSystem3)一系列HDFS API *** 作
package com.haglife.bigdata.hadoop.hdfs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import java.net.URI; public class HDFSApp { public static void main(String[] args) throws Exception { Configuration configuration = new Configuration(); // *** 作HDFS文件系统入口 FileSystem fileSystem = FileSystem.get(new URI("hdfs://masternode:8020"), configuration, "uname"); Path path = new Path("/hdfsapi/test"); boolean result = fileSystem.mkdirs(path); System.out.println(result); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)