hdfs创建文件夹及目录



import java.io.IOException;
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 nkdirDemo {
	public static void main(String [] args) throws IOException, URISyntaxException {
	FileSystem fs = FileSystem.get(new URI("hdfs://Master:9000"), new Configuration());
	fs.mkdirs(new Path("/aaa/bbb/ccc"));//创建文件夹
	fs.create(new Path("/aaa/bbb/ccc/ddd.txt"));//创建文件
	fs.delete(new Path("/user/hadoop/file4.abc"));//删除文件,不常用
	
	fs.close();
		
	}

}

你可能感兴趣的:(hdfs,hdfs)