大数据入门(6)hdfs的客户端java

版权声明: https://blog.csdn.net/u011518709/article/details/83893932

从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);
    }
 

猜你喜欢

转载自blog.csdn.net/u011518709/article/details/83893932