1. 테스트 프로그램 작성
% mkdir ~/work % cd ~/work % vi URLCat.java import java.io.InputStream; 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); } } }
2. 실행
javac URLCat.java -classpath /opt/cloudera/parcels/CDH/lib/hadoop/client/hadoop-common.jar jar cvf URLCat.jar URLCat.class hadoop jar URLCat.jar URLCat hdfs://server01.cloudera.cdh/user/{usename}/quangle.txt