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()) ) {
           writer.write(line+LS);
       }
       
       reader.close(); reader = null;
       writer.close(); writer = null;
     }
Advertisements