Reading a GZIP file from a FileChannel (Java NIO)
问题 I need to read/unpack a .gz file given a FileChannel. I've played around with extracting GZIP archives using GZIPInputStream, but this won't take a FileChannel. I don't have access to the original FileInputStream that the FileChannel was taken from. If someone could tell me a good way (or at least any way) of reading GZIP from a FileChannel, I would greatly appreciate it. Adapted from a question on the Sun Oracle forums. 回答1: You could obtain a wrapping InputStream around the FileChannel: