Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import java.util.zip.GZIPInputStream;

public class Main {
    public static void gunzip(File inFile, File outFile) {
        System.out.println("Expanding " + inFile.getAbsolutePath() + " to " + outFile.getAbsolutePath());

        FileOutputStream out = null;
        GZIPInputStream zIn = null;
        FileInputStream fis = null;
        try {
            out = new FileOutputStream(outFile);
            fis = new FileInputStream(inFile);
            zIn = new GZIPInputStream(fis);
            byte[] buffer = new byte[8 * 1024];
            int count = 0;
            do {
                out.write(buffer, 0, count);
                count = zIn.read(buffer, 0, buffer.length);
            } while (count != -1);
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}