Here you can find the source of toInputStream(File file)
private static InputStream toInputStream(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPInputStream; public class Main { private static InputStream toInputStream(File file) throws IOException { InputStream in = new FileInputStream(file); if (file.getName().endsWith(".gz")) { in = new GZIPInputStream(in); }//from w ww .j a va 2 s .c o m return in; } }