gzip file using java

Searching in gzip file using java was way too easy then I thought–

    public static void gzipTest(String gzFileName,
            String outFileName) 
        throws Throwable { 
        File gzFile = new File(gzFileName);
        BufferedReader reader = null;
        reader = new BufferedReader(
            new InputStreamReader(
            new GZIPInputStream(
            new FileInputStream(gzFile))));
       BufferedWriter writer = null;
       writer = new BufferedWriter(new FileWriter(outFileName));
       String line = null;
       while( null != (line = reader.readLine()) ) {
       reader.close(); reader = null;
       writer.close(); writer = null;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s