code: public static <T, F extends FileInputFormat<T>> F openInput(
  			Class<F> inputFormatClass, String path, Configuration configuration)
  		throws IOException
  	{
  		configuration = configuration == null ? new Configuration() : configuration;
  
  		Path normalizedPath = normalizePath(new Path(path));
  		final F inputFormat = ReflectionUtil.newInstance(inputFormatClass);
  
  		inputFormat.setFilePath(normalizedPath);
  		inputFormat.setOpenTimeout(0);
  		inputFormat.configure(configuration);
  
  		final FileSystem fs = FileSystem.get(normalizedPath.toUri());
  		FileStatus fileStatus = fs.getFileStatus(normalizedPath);
  
  		BlockLocation[] blocks = fs.getFileBlockLocations(fileStatus, 0, fileStatus.getLen());
  		inputFormat.open(new FileInputSplit(0, new Path(path), 0, fileStatus.getLen(), blocks[0].getHosts()));
  		return inputFormat;
  	}
docs: Creates an {@link InputFormat} from a given class for the specified file. The optional {@link Configuration}
  initializes the format.
  
  @param <T>
  the class of the InputFormat
  @param inputFormatClass
  the class of the InputFormat
  @param path
  the path of the file
  @param configuration
  optional configuration of the InputFormat
  @return the created {@link InputFormat}
  @throws IOException
  if an I/O error occurred while accessing the file or initializing the InputFormat.