FileSystem fs=FileSystem.get(new URI("hdfs://hadoop:9000"), new Configuration());
//创建文件夹
fs.mkdirs(new Path("hdfs://hadoop:9000/zys2"));
//上传文件
FSDataOutputStream out=fs.create(new Path("hdfs://hadoop:9000/zys2/upload/DFA"));
FileInputStream in=new FileInputStream("文件路径");
IOUtils.copyBytes(in, out, 1024,true);
//下载文件
FSDataInputStream in=fs.open(new Path("hdfs://hadoop:9000/zys2/upload/DFA"));
FileOutputStream out=new FileOutputStream("文件路径");
IOUtils.copyBytes(in, out, 1024,true);
//删除文件
fs.delete(new Path("hdfs://hadoop:9000/zys2"),true);