1、把hadoop安装包解压到c盘

2、下载hadoop-eclipse.rar,把hadoop.dll和winutile.exe放到hadoop的bin文件夹中

3、修改环境变量

 

hadoop-eclipse-plugin-2.7.3.jar包拷在安装路径的plugins的文件中,然后重启eclipse

4、新建map/reduce项目

host和port与master保持一致 

 

 

读取系统文件:

public class URLCat {

	static {
		URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
	}
	
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

	    InputStream  in =null;
	    //String url=args[0];
	    String url="hdfs://192.168.10.130:9000/test/test1.txt";//只需修改此处

	    try {
	    	in=new URL(url).openStream();
	    	IOUtils.copyBytes(in, System.out, 4096,false);
	    }finally{
	    	IOUtils.closeStream(in);
	    }
	    	
	}

}

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐