Hadoop2.5.0 Client USE

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rentian1/article/details/88775085

requires


hadoop 2.5.0  running

hostname mapping

eclipse config



package com.dasenlin.hadoop;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

/**
 * hadoop client use
 *
 */
public class App 
{
    public static void main( String[] args ){
        Configuration hadoopconf = new Configuration();
        org.apache.hadoop.fs.FSDataInputStream  inStream =null;
        try {
            FileSystem fileSystem = FileSystem.get(hadoopconf);
            Path path = new Path("/user/jasper/conf/tmp/core-site.xml");
            inStream = fileSystem.open(path);
            IOUtils.copyBytes(inStream, System.out, 4096,false);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(null!=inStream)IOUtils.closeStream(inStream);
        }
        
    }
}

 

猜你喜欢

转载自blog.csdn.net/rentian1/article/details/88775085