package readgzipfile;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;

public class ReadGZipViaStream {
	public static void main(String[] args) {
		String fileName = "sample.csv.gz";

		try (InputStream fileInputStream = ReadGZipViaStream.class.getClassLoader().getResourceAsStream(fileName);
				GZIPInputStream gzipInputStream = new GZIPInputStream(fileInputStream);
				BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gzipInputStream))) {

			bufferedReader.lines().forEach(System.out::println);

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
