Hadoop 用命令行编译URLCat

2014-11-24 02:56:08 · 作者: · 浏览: 3

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;


import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;



public class URLCat {
static{
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
}
public static void main(String args[]) throws Exception{
InputStream in = null;
try{
in = new URL(args[0]).openStream();
IOUtils.copyBytes(in, System.out, 4096, false);
}finally{
IOUtils.closeStream(in);
}
}
}


编译


javac -classpath hadoop-core-1.1.2.jar -d secondProject secondProject/URLCat.java


生成JAR


jar -cvf URLCat.jar -C secondProject/ .


hadoop jar URLCat.jar URLCat hdfs://localhost:49000/user/hadoop/input/file01


路径根据



fs.default.name
hdfs://localhost:49000


调整