Here you can find the source of gunzip(File gzippedFile, File destinationFile)
Parameter | Description |
---|---|
gzippedFile | The file to uncompress |
destinationFile | The resulting file |
Parameter | Description |
---|
public static void gunzip(File gzippedFile, File destinationFile) throws IOException
//package com.java2s; /*//from w ww. jav a2 s . c om * Copyright (c) 2002-2006 The European Bioinformatics Institute, and others. * All rights reserved. Please see the file LICENSE * in the root directory of this distribution. */ import java.io.*; import java.util.zip.*; public class Main { /** * Uncompress gzipped files * @param gzippedFile The file to uncompress * @param destinationFile The resulting file * @throws java.io.IOException thrown if there is a problem finding or writing the files */ public static void gunzip(File gzippedFile, File destinationFile) throws IOException { int buffer = 2048; FileInputStream in = new FileInputStream(gzippedFile); GZIPInputStream zipin = new GZIPInputStream(in); byte[] data = new byte[buffer]; // decompress the file FileOutputStream out = new FileOutputStream(destinationFile); try { int length; while ((length = zipin.read(data, 0, buffer)) != -1) out.write(data, 0, length); } finally { out.close(); zipin.close(); in.close(); } } }