hadoop集群上传下载文件
//读入数据:从云端到本机(提取数据)private static void readFromHdfs()throws FileNotFoundException,IOException{//云端地址String dest = "hdfs://192.168.1.11:9000/usr/Google_三大论文中文版.pdf";//我的目录地址String mySrc = "H://Google_三大论文中文版.pdf";//得到配置Configuration conf = new Configuration();//实例化文件系统FileSystem fs = FileSystem.get(URI.create(dest), conf);//读出流FSDataInputStream hdfsInStream = fs.open(new Path(dest));//写入流OutputStream out = new FileOutputStream(mySrc);//将InputStrteam 中的内容通过IOUtils的copyBytes方法复制到out中IOUtils.copyBytes(hdfsInStream, out, 4096,true);}
?
这是一个小小的开端,今年要开始认真研究了!
?