package com.yoyosys.cebbank.bdap.service.mr; import java.io.IOException; import java.io.InputStream; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; /** * * @author Administrator * */ //直接使用FileSystem以標準輸出格式顯示hadoop文件系統中的文件 public class FileSystemCat { public static void main(String[] args) throws IOException { String uri = args[0]; Configuration conf = new Configuration(); FileSystem fs = FileSystem.get(conf); InputStream in = null; try { in = fs.open(new Path(uri)); IOUtils.copyBytes(in, System.out, 4094,false); } catch (Exception e) { // TODO: handle exception IOUtils.closeStream(in); } } }