THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
h1. Component Overview Compress is an API for working with tar, zip and bzip2 filesthe various archiving and compression formats. h1. Quick Start *compress\* is divided between Compressors and Archivers. While you have to get an Archiver from a factory when just archiving one or more files to the target file (tar), you'll need a Compressor for reducing the files size (bzip2). Please note: There are a stream based API. Some of it's original code came from Avalon's Excalibur, but originally from Ant, as far as life in Apache goes. It has migrated via: Ant \-> Avalon-Excalibur \-> Commons-IO \-> Commons-Compress. More credits can be found in NOTICE.txt file. *compress\* divides the implementation in Compressors and Archivers. For each one an factory is implemented. Basically you have to get the stream implementation from the factory, create an entry, put this into the stream and stream. Some experimental code makes it possible to modify archiver and compressor files. This means you can delete from for example a zip file. Historical notes: There were discussion of "sponsoring" compress with code from [TrueZip] (https://truezip.dev.java.net/) and of enhancing compress design. At the moment the current implementation is considered as complex by some people. An deeper look at compress ). The result was, not to include any code from this project (see mailinglists). There was a discussion about the complex file based implementation too. The result was to start again with a stream based implementation and move the old one to a branch. More information about the old implementation can be found on the [CompressImplementationDetails] page. h1. Roadmap We're currenlty discussing a 2.0 API that fully embraces generics and tries to address a few pain points discovered over the years Compress 1.x has been around. If you want to help, here is the [CompressRoadmap]. h2. Archiver To pack an archive, you have to get an archiver stream via the [ArchiverFactory]. At the moment it's possible to get a "zip" or a "tar" archiver. Add your files streams to the archiver and call save to store the archivestream. Archiver streams are: ZIP, CPIO, AR, TAR, JAR, DUMP. 7z, ARJ. h3. Packing Creating a ZIP-File {{{Archive archiver = [ArchiverFactory].getInstancefinal [OutputStream] out = new [FileOutputStream](output); [ArchiveOutputStream] os = new [ArchiveStreamFactory]().createArchiveOutputStream("zip", out); archiveros.addputArchiveEntry(new File("C:\\Temp\\1.html[ZipArchiveEntry]("testdata/test1.xml")); archiver.add( new File("C:\\Temp\\1.html.bz2IOUtils.copy(new [FileInputStream](file1), os); os.closeArchiveEntry(); os.putArchiveEntry(new [ZipArchiveEntry]("testdata/test2.xml")); archiverIOUtils.savecopy(new File("C:\\Temp\\ZIPTEST.zip")[FileInputStream](file2), os); os.closeArchiveEntry(); out.finish(); os.close();}}} h3. Unpacking a ZIP-File {{{Archive archiver = [ArchiverFactory].getInstance( new File("C:\\Temp\\ZIPTEST.zip")); archiver.unpack( new File("C:\\Temp\\unpacked\\")final [InputStream] is = new [FileInputStream](input); [ArchiveInputStream] in = new [ArchiveStreamFactory]().createArchiveInputStream("zip", is); [ZipArchiveEntry] entry = (ZipArchiveEntry)in.getNextEntry(); [OutputStream] out = new [FileOutputStream](new File(dir, entry.getName())); IOUtils.copy(in, out); out.close(); in.close();}}} h2. Compressor Same goes for Compressor. At the moment there is only "bz2" supportCompressor streams are: bz2, gz, lzma, xz, pack200, Z. h3. Compressing a file {{{Compressor compressor; compressor = [CompressorFactory].getInstance("bz2"); compressor.compressToHere( new File("C:\\Temp\\test.tar")final [OutputStream] out = new [BufferedOutputStream](new [FileOutputStream](output)); [CompressorOutputStream] cos = new [CompressorStreamFactory]().createCompressorOutputStream("bzip2", out); IOUtils.copy(new [FileInputStream](input), cos); cos.close();}}} h3. Decompressing a file {{{Compressor decompressor; decompressor = [CompressorFactory].getInstance("bz2"); decompressor.decompressTo( new File("C:\\Temp\\asf-logo-huge.tar.bz2"), new File("C:\\Temp\\asf-logo-huge.tar")final [InputStream] is = new [BufferedInputStream](new [FileInputStream](input)); [CompressorInputStream] in = new [CompressorStreamFactory]().createCompressorInputStream("bzip2", is); IOUtils.copy(in, new [FileOutputStream](output)); in.close();}}} h1. FAQ |Add your questions/answers here.| h1. TODO - Add delete features - Enhance implementation design