Hadoop 获取Input File的文件名

写Hadoop程序的时候在Mapper里遇到这个需求,上网查了下,做个记录:

public static class MapClass extends MapReduceBase implements
            Mapper<Object, Text, IntWritable, Text> {

        @Override
        public void map(Object k, Text value,
                OutputCollector<IntWritable, Text> output, Reporter reporter)
                throws IOException {
            // TODO Auto-generated method stub

            FileSplit fileSplit = (FileSplit) reporter.getInputSplit();
            String fileName = fileSplit.getPath().getName();
           
        }
    }
原文地址:https://www.cnblogs.com/Murcielago/p/4383177.html