FileDocCategorySizeDatePackage
BZip2Resource.javaAPI DocApache Ant 1.702748Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.types.resources

BZip2Resource

public class BZip2Resource extends CompressedResource
A Bzip2 compressed resource.

Wraps around another resource, delegates all quries to that other resource but uncompresses/compresses streams on the fly.

since
Ant 1.7

Fields Summary
private static final char[]
MAGIC
Constructors Summary
public BZip2Resource()
A no-arg constructor


        
      
    
public BZip2Resource(org.apache.tools.ant.types.ResourceCollection other)
Constructor with another resource to wrap.

param
other the resource to wrap.

        super(other);
    
Methods Summary
protected java.lang.StringgetCompressionName()
Get the name of the compression method.

return
the string "Bzip2".

        return "Bzip2";
    
protected java.io.InputStreamwrapStream(java.io.InputStream in)
Decompress on the fly using {@link CBZip2InputStream}.

param
in the stream to wrap.
return
the wrapped stream.
throws
IOException if there is a problem.

        for (int i = 0; i < MAGIC.length; i++) {
            if (in.read() != MAGIC[i]) {
                throw new IOException("Invalid bz2 stream.");
            }
        }
        return new CBZip2InputStream(in);
    
protected java.io.OutputStreamwrapStream(java.io.OutputStream out)
Compress on the fly using {@link CBZip2OutputStream}.

param
out the stream to wrap.
return
the wrapped stream.
throws
IOException if there is a problem.

        for (int i = 0; i < MAGIC.length; i++) {
            out.write(MAGIC[i]);
        }
        return new CBZip2OutputStream(out);