org.apache.commons.compress
Class AbstractCompressor

java.lang.Object
  extended by org.apache.commons.compress.PackableObject
      extended by org.apache.commons.compress.AbstractCompressor
All Implemented Interfaces:
Compressor
Direct Known Subclasses:
BZip2Compressor

public abstract class AbstractCompressor
extends PackableObject
implements Compressor

AbstractCompressor handles all compression/decompression actions on an abstract basis.


Field Summary
 
Fields inherited from class org.apache.commons.compress.PackableObject
CHOOSE_EXTENSION, CHOOSE_NAME
 
Constructor Summary
AbstractCompressor()
           
 
Method Summary
 InputStream compress(File input)
          Compresses this file and returns an InputStream to the compressed File
 InputStream compress(InputStream input)
          Compresses this InputStream and returns an InputStream to the compressed file
 void compressTo(File input, File output)
          Creates the file "output" with the compressed content of file "input"
 void compressToHere(File input)
          Compresses the file input and creates a file in the same directory with the default file extension in its name.
 InputStream decompress(File input)
          Decompresses a file and returns an InputStream
 InputStream decompress(InputStream input)
          Decompresses a file and returns an InputStream
 void decompressTo(File input, File output)
          Decompresses this file and writes the decompressed byte to the output file
abstract  String getDefaultFileExtension()
          Returns a String with the default file extension for this compressor.
 
Methods inherited from class org.apache.commons.compress.PackableObject
getHeader, getName, identifyByHeader, isPackableWith
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.compress.Compressor
compressTo, decompressTo
 

Constructor Detail

AbstractCompressor

public AbstractCompressor()
Method Detail

getDefaultFileExtension

public abstract String getDefaultFileExtension()
Returns a String with the default file extension for this compressor. For example, a zip-files default file extension would be "zip" (without leading dot).

Specified by:
getDefaultFileExtension in class PackableObject
Returns:
the default file extension

compress

public InputStream compress(InputStream input)
                     throws CompressException
Description copied from interface: Compressor
Compresses this InputStream and returns an InputStream to the compressed file

Specified by:
compress in interface Compressor
Parameters:
input - Stream to compress
Returns:
Stream to the compressed file
Throws:
CompressException - if the Compressor reports an error

compressTo

public void compressTo(File input,
                       File output)
                throws CompressException
Description copied from interface: Compressor
Creates the file "output" with the compressed content of file "input"

Specified by:
compressTo in interface Compressor
Parameters:
input - the file to compress
output - the file to create
Throws:
CompressException - if the Compressor reports an error

compressToHere

public void compressToHere(File input)
                    throws CompressException
Description copied from interface: Compressor
Compresses the file input and creates a file in the same directory with the default file extension in its name.

Specified by:
compressToHere in interface Compressor
Parameters:
input - the file to compress
Throws:
CompressException - if the Compressor reports an error

compress

public InputStream compress(File input)
                     throws CompressException
Description copied from interface: Compressor
Compresses this file and returns an InputStream to the compressed File

Specified by:
compress in interface Compressor
Parameters:
input - File to compress
Returns:
InputStream of the compressed file
Throws:
CompressException - if the Compressor reports an error

decompress

public InputStream decompress(File input)
                       throws CompressException
Description copied from interface: Compressor
Decompresses a file and returns an InputStream

Specified by:
decompress in interface Compressor
Parameters:
input - file to decompress
Returns:
the decompressed file as an inputstream
Throws:
CompressException

decompress

public InputStream decompress(InputStream input)
                       throws CompressException
Description copied from interface: Compressor
Decompresses a file and returns an InputStream

Specified by:
decompress in interface Compressor
Parameters:
input - inputstream to decompress
Returns:
the decompressed InputStream
Throws:
CompressException

decompressTo

public void decompressTo(File input,
                         File output)
                  throws CompressException
Description copied from interface: Compressor
Decompresses this file and writes the decompressed byte to the output file

Specified by:
decompressTo in interface Compressor
Parameters:
input - File to decompress
output - File to write the decompressed bytes to
Throws:
CompressException - if the Compressor reports an error


Copyright © 2011 Apache Software Foundation. All Rights Reserved.