private long getCachedStartIndex(Path path) throws IOException {
    if (headerCount == 0) {
      return 0;
    }
    Long startIndexForFile = startIndexMap.get(path);
    if (startIndexForFile == null) {
      FileSystem fileSystem;
      FSDataInputStream fis = null;
      fileSystem = path.getFileSystem(conf);
      try {
        fis = fileSystem.open(path);
        long currPos = fis.getPos();
        int delimiterIdx = -1;
        for (int j = 0; j < headerCount; j++) {
          String headerLine = fis.readLine();
          if (headerLine == null) {
            startIndexMap.put(path, Long.MAX_VALUE);
            return Long.MAX_VALUE;
          }
          if (j == headerCount-1) {
            String delimiter = conf.get("textinputformat.record.delimiter");
            // If record delimiter is defined
            if (delimiter != null && !delimiter.isEmpty()) {
              delimiterIdx = headerLine.indexOf(delimiter);
            } else {
              currPos = fis.getPos();
            }
          } else {
            currPos = fis.getPos();
          }
        }
        // Readers skip the entire first row if the start index of the
        // split is not zero. We are setting the start of the index as
        // the last byte of the previous row so the last line of header
        // is discarded instead of the first valid input row.
        // We consider record delimiters if they exist.
        startIndexForFile = currPos + delimiterIdx;
      } finally {
        if (fis != null) {
          fis.close();
        }
      }
      startIndexMap.put(path, startIndexForFile);
    }
    return startIndexForFile;
  }
SkippingInputFormat is a header/footer aware input format. It truncates
splits identified by TextInputFormat. Header and footers are removed
from the splits.

This InputFormat does NOT support Compressed Files!
ql/src/java/org/apache/hadoop/hive/ql/io/SkippingTextInputFormat.java