hadoop实践02---eclipse操作hdfs的api上传文件
1、eclipse中编写代码后双击main方法--->Run as ---> java application ,然后指定的文件 就会提交到hdfs中。
2、查看文件:http://192.168.108.128:50070/dfshealth.html#tab-overview
package hdfs24; 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; public class hdfsClientDemo { public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); //复本数 conf.set("dfs.replication", "1"); conf.set("dfs.blocksize", "1024m"); FileSystem fs = FileSystem.get(new URI("hdfs://192.168.108.128:9000"), conf, "root"); fs.copyFromLocalFile(new Path("D:/postman-4.1.2.rar"), new Path("/aaa/")); fs.close(); } }