大資料入門(6)hdfs的客戶端java
阿新 • • 發佈:2018-11-10
從hdfs中copy 檔案到當前虛擬機器
1、匯入jar
E:\lib\hadoop-2.4.1\share\hadoop\hdfs
E:\lib\hadoop-2.4.1\share\hadoop\common
2、copy 安裝的Hadoop下的檔案
core-site.xml
hdfs-site.xml
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
String url = "hdfs://192.168.1.115:9000/jdk-7u71-linux-x64.tar.gz";
Path path = new Path();
FSDataInputStream is = fs.open(path);
FileOutputStream os = new FileOutputStream("/home/admin/download/jdk.tar.gz");
IOUtils.copy(is, os);
}