Tuesday, October 13, 2015

Getting input file name in Mapper

Get InputSplit on Context. Cast it to FileSplit and getPath on that 
Path filePath = ((FileSplit) context.getInputSplit()).getPath();
String filePathString = ((FileSplit) context.getInputSplit()).getPath().toString();
String fileName = ((FileSplit) context.getInputSplit()).getPath().getName();