FileDocCategorySizeDatePackage
GUnzip.javaAPI DocApache Ant 1.703296Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs

GUnzip

public class GUnzip extends Unpack
Expands a file that has been compressed with the GZIP algorithm. Normally used to compress non-compressed archives such as TAR files.
since
Ant 1.1
ant.task
category="packaging"

Fields Summary
private static final String
DEFAULT_EXTENSION
Constructors Summary
Methods Summary
protected voidextract()
Implement the gunzipping.

        if (source.lastModified() > dest.lastModified()) {
            log("Expanding " + source.getAbsolutePath() + " to "
                        + dest.getAbsolutePath());

            FileOutputStream out = null;
            GZIPInputStream zIn = null;
            InputStream fis = null;
            try {
                out = new FileOutputStream(dest);
                fis = srcResource.getInputStream();
                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) {
                String msg = "Problem expanding gzip " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
                FileUtils.close(fis);
                FileUtils.close(out);
                FileUtils.close(zIn);
            }
        }
    
protected java.lang.StringgetDefaultExtension()
Get the default extension.

return
the value ".gz"


                 
       
        return DEFAULT_EXTENSION;
    
protected booleansupportsNonFileResources()
Whether this task can deal with non-file resources.

This implementation returns true only if this task is <gunzip>. Any subclass of this class that also wants to support non-file resources needs to override this method. We need to do so for backwards compatibility reasons since we can't expect subclasses to support resources.

return
true if this task supports non file resources.
since
Ant 1.7

        return getClass().equals(GUnzip.class);