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 ReadGZipViaBufferReader {
	public static void main(String[] args) {
		String fileName = "sample.csv.gz";

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

			String line;
			while ((line = bufferedReader.readLine()) != null) {
				System.out.println(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
