@SuppressWarnings("unchecked")
  public static boolean checkInputFormat(FileSystem fs, HiveConf conf,
      Class<? extends InputFormat> inputFormatCls, List<FileStatus> files)
      throws HiveException {
    if (files.isEmpty()) {
      return true;
    }
    Class<? extends InputFormatChecker> checkerCls = FileChecker.getInstance()
        .getInputFormatCheckerClass(inputFormatCls);
    if (checkerCls == null
        && inputFormatCls.isAssignableFrom(TextInputFormat.class)) {
      // we get a text input format here, we can not determine a file is text
      // according to its content, so we can do is to test if other file
      // format can accept it. If one other file format can accept this file,
      // we treat this file as text file, although it maybe not.
      return checkTextInputFormat(fs, conf, files);
    }

    if (checkerCls != null) {
      InputFormatChecker checkerInstance = FileChecker.getInstance()
          .getInputFormatCheckerInstance(checkerCls);
      try {
        if (checkerInstance == null) {
          checkerInstance = checkerCls.newInstance();
          FileChecker.getInstance().putInputFormatCheckerInstance(checkerCls, checkerInstance);
        }
        return checkerInstance.validateInput(fs, conf, files);
      } catch (Exception e) {
        throw new HiveException(e);
      }
    }
    return true;
  }
Checks if files are in same format as the given input format.

Note: an empty set of files is considered compliant.
ql/src/java/org/apache/hadoop/hive/ql/io/HiveFileFormatUtils.java