import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.util.Properties;
public class TestHDFS {
public static void main(String[] args) throws Exception{
Properties properties = System.getProperties();
properties.setProperty("HADOOP_USER_NAME", "root");
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://192.168.0.104:9000");
FileSystem fs = FileSystem.get(conf);
//存在的情况下会覆盖之前的目录
boolean success = fs.mkdirs(new Path("/xiaol"));
System.out.println(success);
}
}
注:在mac电脑设置一样起作用