一、关于hdfs文件的上传
Configuration conf1=new Configuration();
conf1.set("dfs.replication","2");
FileSystem fs = FileSystem.get(new URI("hdfs://localhost:9002"), conf1,"Administrator");
fs.copyFromLocalFile(new Path("D:/eclipse/Java/workspace/test3/input/text03"), new Path("/input/hello5.txt"));
fs.close();
二、从hdfs下载文件到本地
Configuration configuration = new Configuration();
FileSystem fs1 = FileSystem.get(new URI("hdfs://localhost:9002"), configuration,"Administrator");
// 获取输入流
FSDataInputStream fis = fs1.open(new Path("/input/hello5.txt"));
// 创建输出流
FileOutputStream fos = new FileOutputStream(new File("D:/eclipse/Java/workspace/test3/output7"));
IOUtils.copy(fis, fos);