import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.junit.Before;
import org.junit.Test;

import java.net.URI;

public class Java_HDFS {
    //定义文件系统,类变量
    FileSystem fs=null;

    //预处理,定义在@Test之前
    @Before
    public void init() throws Exception {
        //这里id设置自己本虚拟机的id号,root是用户名
        fs=FileSystem.get(new URI("hdfs://192.168.44.128:9000"),new Configuration(),"root");
    }

    @Test
    public void printFS(){
        System.out.println(fs);
    }
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐