code: public InputStream openFile(Path path) throws IOException {
          CompressionCodec codec=compressionCodecs.getCodec(path);
   	FSDataInputStream fileIn=fs.open(path);
  	// check if compressed
  	if (codec==null) { // uncompressed
  	LOG.debug("Reading from an uncompressed file \""+path+"\"");
  		return fileIn;
  	} else { // compressed
  		Decompressor decompressor = CodecPool.getDecompressor(codec);
  		this.openDecompressors.add(decompressor); // to be returned later using close
  		if (codec instanceof SplittableCompressionCodec) {
  			LOG.debug("Reading from a compressed file \""+path+"\" with splittable compression codec");
  			long end = fs.getFileStatus(path).getLen(); 
          		return ((SplittableCompressionCodec)codec).createInputStream(fileIn, decompressor, 0, end,SplittableCompressionCodec.READ_MODE.CONTINUOUS);
        		} else {
  			LOG.debug("Reading from a compressed file \""+path+"\" with non-splittable compression codec");
          		return codec.createInputStream(fileIn,decompressor);
        		}
  	}
  }
docs: /*
  Opens a file using the Hadoop API. It supports uncompressed and compressed files.
  
  @param path path to the file, e.g. file://path/to/file for a local file or hdfs://path/to/file for HDFS file. All filesystem configured for Hadoop can be used
  
  @return InputStream from which the file content can be read
  
  @throws java.io.Exception in case there is an issue reading the file