You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2018/05/06 10:32:06 UTC
[1/5] commons-compress git commit: framed LZ4 also supports
concatenated streams.
Repository: commons-compress
Updated Branches:
refs/heads/master f763ccc0b -> af0f6c83a
framed LZ4 also supports concatenated streams.
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/d6cda401
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/d6cda401
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/d6cda401
Branch: refs/heads/master
Commit: d6cda4012ec24ef9512220f586cca241b7da4da4
Parents: f763ccc
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun May 6 12:08:16 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun May 6 12:08:16 2018 +0200
----------------------------------------------------------------------
src/site/xdoc/examples.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/d6cda401/src/site/xdoc/examples.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index 98f9846..0f6294c 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -105,7 +105,8 @@ CompressorInputStream input = new CompressorStreamFactory()
</subsection>
<subsection name="Concatenated Streams">
- <p>For the bzip2, gzip and xz formats a single compressed file
+ <p>For the bzip2, gzip and xz formats as well as the framed
+ lz4 format a single compressed file
may actually consist of several streams that will be
concatenated by the command line utilities when decompressing
them. Starting with Commons Compress 1.4 the
[3/5] commons-compress git commit: alpha-sort formats
Posted by bo...@apache.org.
alpha-sort formats
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b78ced2f
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b78ced2f
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b78ced2f
Branch: refs/heads/master
Commit: b78ced2f4a3797b3cac85807a292f774cab2dab8
Parents: 66347f4
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun May 6 12:24:55 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun May 6 12:24:55 2018 +0200
----------------------------------------------------------------------
src/site/xdoc/examples.xml | 526 ++++++++++++++++++++--------------------
1 file changed, 263 insertions(+), 263 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b78ced2f/src/site/xdoc/examples.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index c4f1f31..a9154ab 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -119,6 +119,80 @@ CompressorInputStream input = new CompressorStreamFactory()
</subsection>
+ <subsection name="7z">
+
+ <p>Note that Commons Compress currently only supports a subset
+ of compression and encryption algorithms used for 7z archives.
+ For writing only uncompressed entries, LZMA, LZMA2, BZIP2 and
+ Deflate are supported - in addition to those reading supports
+ AES-256/SHA-256 and DEFLATE64.</p>
+
+ <p>Multipart archives are not supported at all.</p>
+
+ <p>7z archives can use multiple compression and encryption
+ methods as well as filters combined as a pipeline of methods
+ for its entries. Prior to Compress 1.8 you could only specify
+ a single method when creating archives - reading archives
+ using more than one method has been possible before. Starting
+ with Compress 1.8 it is possible to configure the full
+ pipeline using the <code>setContentMethods</code> method of
+ <code>SevenZOutputFile</code>. Methods are specified in the
+ order they appear inside the pipeline when creating the
+ archive, you can also specify certain parameters for some of
+ the methods - see the Javadocs of
+ <code>SevenZMethodConfiguration</code> for details.</p>
+
+ <p>When reading entries from an archive the
+ <code>getContentMethods</code> method of
+ <code>SevenZArchiveEntry</code> will properly represent the
+ compression/encryption/filter methods but may fail to
+ determine the configuration options used. As of Compress 1.8
+ only the dictionary size used for LZMA2 can be read.</p>
+
+ <p>Currently solid compression - compressing multiple files
+ as a single block to benefit from patterns repeating accross
+ files - is only supported when reading archives. This also
+ means compression ratio will likely be worse when using
+ Commons Compress compared to the native 7z executable.</p>
+
+ <p>Reading or writing requires a
+ <code>SeekableByteChannel</code> that will be obtained
+ transparently when reading from or writing to a file. The
+ class
+ <code>org.apache.commons.compress.utils.SeekableInMemoryByteChannel</code>
+ allows you to read from or write to an in-memory archive.</p>
+
+ <p>Adding an entry to a 7z archive:</p>
+<source><![CDATA[
+SevenZOutputFile sevenZOutput = new SevenZOutputFile(file);
+SevenZArchiveEntry entry = sevenZOutput.createArchiveEntry(fileToArchive, name);
+sevenZOutput.putArchiveEntry(entry);
+sevenZOutput.write(contentOfEntry);
+sevenZOutput.closeArchiveEntry();
+]]></source>
+
+ <p>Uncompressing a given 7z archive (you would
+ certainly add exception handling and make sure all streams
+ get closed properly):</p>
+<source><![CDATA[
+SevenZFile sevenZFile = new SevenZFile(new File("archive.7z"));
+SevenZArchiveEntry entry = sevenZFile.getNextEntry();
+byte[] content = new byte[entry.getSize()];
+LOOP UNTIL entry.getSize() HAS BEEN READ {
+ sevenZFile.read(content, offset, content.length - offset);
+}
+]]></source>
+
+ <p>Uncompressing a given in-memory 7z archive:</p>
+ <source><![CDATA[
+byte[] inputData; // 7z archive contents
+SeekableInMemoryByteChannel inMemoryByteChannel = new SeekableInMemoryByteChannel(inputData);
+SevenZFile sevenZFile = new SevenZFile(inMemoryByteChannel);
+SevenZArchiveEntry entry = sevenZFile.getNextEntry();
+sevenZFile.read(); // read current entry's data
+]]></source>
+ </subsection>
+
<subsection name="ar">
<p>In addition to the information stored
@@ -185,6 +259,23 @@ LOOP UNTIL entry.getSize() HAS BEEN READ {
</subsection>
+ <subsection name="arj">
+
+ <p>Note that Commons Compress doesn't support compressed,
+ encrypted or multi-volume ARJ archives, yet.</p>
+
+ <p>Uncompressing a given arj archive (you would
+ certainly add exception handling and make sure all streams
+ get closed properly):</p>
+<source><![CDATA[
+ArjArchiveEntry entry = arjInput.getNextEntry();
+byte[] content = new byte[entry.getSize()];
+LOOP UNTIL entry.getSize() HAS BEEN READ {
+ arjInput.read(content, offset, content.length - offset);
+}
+]]></source>
+ </subsection>
+
<subsection name="cpio">
<p>In addition to the information stored
@@ -225,6 +316,49 @@ LOOP UNTIL entry.getSize() HAS BEEN READ {
</subsection>
+ <subsection name="jar">
+ <p>In general, JAR archives are ZIP files, so the JAR package
+ supports all options provided by the <a href="#zip">ZIP</a> package.</p>
+
+ <p>To be interoperable JAR archives should always be created
+ using the UTF-8 encoding for file names (which is the
+ default).</p>
+
+ <p>Archives created using <code>JarArchiveOutputStream</code>
+ will implicitly add a <code>JarMarker</code> extra field to
+ the very first archive entry of the archive which will make
+ Solaris recognize them as Java archives and allows them to
+ be used as executables.</p>
+
+ <p>Note that <code>ArchiveStreamFactory</code> doesn't
+ distinguish ZIP archives from JAR archives, so if you use
+ the one-argument <code>createArchiveInputStream</code>
+ method on a JAR archive, it will still return the more
+ generic <code>ZipArchiveInputStream</code>.</p>
+
+ <p>The <code>JarArchiveEntry</code> class contains fields for
+ certificates and attributes that are planned to be supported
+ in the future but are not supported as of Compress 1.0.</p>
+
+ <p>Adding an entry to a jar archive:</p>
+<source><![CDATA[
+JarArchiveEntry entry = new JarArchiveEntry(name, size);
+entry.setSize(size);
+jarOutput.putArchiveEntry(entry);
+jarOutput.write(contentOfEntry);
+jarOutput.closeArchiveEntry();
+]]></source>
+
+ <p>Reading entries from an jar archive:</p>
+<source><![CDATA[
+JarArchiveEntry entry = jarInput.getNextJarEntry();
+byte[] content = new byte[entry.getSize()];
+LOOP UNTIL entry.getSize() HAS BEEN READ {
+ jarInput.read(content, offset, content.length - offset);
+}
+]]></source>
+ </subsection>
+
<subsection name="dump">
<p>In addition to the information stored
@@ -356,144 +490,10 @@ public class ScatterSample {
throws IOException, ExecutionException, InterruptedException {
dirs.writeTo(zipArchiveOutputStream);
dirs.close();
- scatterZipCreator.writeTo(zipArchiveOutputStream);
- }
-}
-</source>
- </subsection>
-
- <subsection name="jar">
- <p>In general, JAR archives are ZIP files, so the JAR package
- supports all options provided by the ZIP package.</p>
-
- <p>To be interoperable JAR archives should always be created
- using the UTF-8 encoding for file names (which is the
- default).</p>
-
- <p>Archives created using <code>JarArchiveOutputStream</code>
- will implicitly add a <code>JarMarker</code> extra field to
- the very first archive entry of the archive which will make
- Solaris recognize them as Java archives and allows them to
- be used as executables.</p>
-
- <p>Note that <code>ArchiveStreamFactory</code> doesn't
- distinguish ZIP archives from JAR archives, so if you use
- the one-argument <code>createArchiveInputStream</code>
- method on a JAR archive, it will still return the more
- generic <code>ZipArchiveInputStream</code>.</p>
-
- <p>The <code>JarArchiveEntry</code> class contains fields for
- certificates and attributes that are planned to be supported
- in the future but are not supported as of Compress 1.0.</p>
-
- <p>Adding an entry to a jar archive:</p>
-<source><![CDATA[
-JarArchiveEntry entry = new JarArchiveEntry(name, size);
-entry.setSize(size);
-jarOutput.putArchiveEntry(entry);
-jarOutput.write(contentOfEntry);
-jarOutput.closeArchiveEntry();
-]]></source>
-
- <p>Reading entries from an jar archive:</p>
-<source><![CDATA[
-JarArchiveEntry entry = jarInput.getNextJarEntry();
-byte[] content = new byte[entry.getSize()];
-LOOP UNTIL entry.getSize() HAS BEEN READ {
- jarInput.read(content, offset, content.length - offset);
-}
-]]></source>
- </subsection>
-
- <subsection name="7z">
-
- <p>Note that Commons Compress currently only supports a subset
- of compression and encryption algorithms used for 7z archives.
- For writing only uncompressed entries, LZMA, LZMA2, BZIP2 and
- Deflate are supported - reading also supports
- AES-256/SHA-256 and DEFLATE64.</p>
-
- <p>Multipart archives are not supported at all.</p>
-
- <p>7z archives can use multiple compression and encryption
- methods as well as filters combined as a pipeline of methods
- for its entries. Prior to Compress 1.8 you could only specify
- a single method when creating archives - reading archives
- using more than one method has been possible before. Starting
- with Compress 1.8 it is possible to configure the full
- pipeline using the <code>setContentMethods</code> method of
- <code>SevenZOutputFile</code>. Methods are specified in the
- order they appear inside the pipeline when creating the
- archive, you can also specify certain parameters for some of
- the methods - see the Javadocs of
- <code>SevenZMethodConfiguration</code> for details.</p>
-
- <p>When reading entries from an archive the
- <code>getContentMethods</code> method of
- <code>SevenZArchiveEntry</code> will properly represent the
- compression/encryption/filter methods but may fail to
- determine the configuration options used. As of Compress 1.8
- only the dictionary size used for LZMA2 can be read.</p>
-
- <p>Currently solid compression - compressing multiple files
- as a single block to benefit from patterns repeating accross
- files - is only supported when reading archives. This also
- means compression ratio will likely be worse when using
- Commons Compress compared to the native 7z executable.</p>
-
- <p>Reading or writing requires a
- <code>SeekableByteChannel</code> that will be obtained
- transparently when reading from or writing to a file. The
- class
- <code>org.apache.commons.compress.utils.SeekableInMemoryByteChannel</code>
- allows you to read from or write to an in-memory archive.</p>
-
- <p>Adding an entry to a 7z archive:</p>
-<source><![CDATA[
-SevenZOutputFile sevenZOutput = new SevenZOutputFile(file);
-SevenZArchiveEntry entry = sevenZOutput.createArchiveEntry(fileToArchive, name);
-sevenZOutput.putArchiveEntry(entry);
-sevenZOutput.write(contentOfEntry);
-sevenZOutput.closeArchiveEntry();
-]]></source>
-
- <p>Uncompressing a given 7z archive (you would
- certainly add exception handling and make sure all streams
- get closed properly):</p>
-<source><![CDATA[
-SevenZFile sevenZFile = new SevenZFile(new File("archive.7z"));
-SevenZArchiveEntry entry = sevenZFile.getNextEntry();
-byte[] content = new byte[entry.getSize()];
-LOOP UNTIL entry.getSize() HAS BEEN READ {
- sevenZFile.read(content, offset, content.length - offset);
-}
-]]></source>
-
- <p>Uncompressing a given in-memory 7z archive:</p>
- <source><![CDATA[
-byte[] inputData; // 7z archive contents
-SeekableInMemoryByteChannel inMemoryByteChannel = new SeekableInMemoryByteChannel(inputData);
-SevenZFile sevenZFile = new SevenZFile(inMemoryByteChannel);
-SevenZArchiveEntry entry = sevenZFile.getNextEntry();
-sevenZFile.read(); // read current entry's data
-]]></source>
- </subsection>
-
- <subsection name="arj">
-
- <p>Note that Commons Compress doesn't support compressed,
- encrypted or multi-volume ARJ archives, yet.</p>
-
- <p>Uncompressing a given arj archive (you would
- certainly add exception handling and make sure all streams
- get closed properly):</p>
-<source><![CDATA[
-ArjArchiveEntry entry = arjInput.getNextEntry();
-byte[] content = new byte[entry.getSize()];
-LOOP UNTIL entry.getSize() HAS BEEN READ {
- arjInput.read(content, offset, content.length - offset);
+ scatterZipCreator.writeTo(zipArchiveOutputStream);
+ }
}
-]]></source>
+</source>
</subsection>
</section>
@@ -575,153 +575,128 @@ in.close();
</subsection>
- <subsection name="gzip">
+ <subsection name="DEFLATE">
<p>The implementation of the DEFLATE/INFLATE code used by this
package is provided by the <code>java.util.zip</code> package
of the Java class library.</p>
- <p>Uncompressing a given gzip compressed file (you would
+ <p>Uncompressing a given DEFLATE compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("archive.tar.gz"));
+InputStream fin = Files.newInputStream(Paths.get("some-file"));
BufferedInputStream in = new BufferedInputStream(fin);
OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
+DeflateCompressorInputStream defIn = new DeflateCompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
-while (-1 != (n = gzIn.read(buffer))) {
+while (-1 != (n = defIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
-gzIn.close();
+defIn.close();
]]></source>
- <p>Compressing a given file using gzip (you would
+ <p>Compressing a given file using DEFLATE (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
InputStream in = Files.newInputStream(Paths.get("archive.tar"));
-OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.gz"));
+OutputStream fout = Files.newOutputStream(Paths.get("some-file"));
BufferedOutputStream out = new BufferedOutputStream(fout);
-GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(out);
+DeflateCompressorOutputStream defOut = new DeflateCompressorOutputStream(out);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = in.read(buffer))) {
- gzOut.write(buffer, 0, n);
+ defOut.write(buffer, 0, n);
}
-gzOut.close();
+defOut.close();
in.close();
]]></source>
</subsection>
- <subsection name="Pack200">
-
- <p>The Pack200 package has a <a href="pack200.html">dedicated
- documentation page</a>.</p>
-
- <p>The implementation of this package is provided by
- the <code>java.util.zip</code> package of the Java class
- library.</p>
+ <subsection name="DEFLATE64">
- <p>Uncompressing a given pack200 compressed file (you would
+ <p>Uncompressing a given DEFLATE64 compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("archive.pack"));
+InputStream fin = Files.newInputStream(Paths.get("some-file"));
BufferedInputStream in = new BufferedInputStream(fin);
-OutputStream out = Files.newOutputStream(Paths.get("archive.jar"));
-Pack200CompressorInputStream pIn = new Pack200CompressorInputStream(in);
+OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
+Deflate64CompressorInputStream defIn = new Deflate64CompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
-while (-1 != (n = pIn.read(buffer))) {
+while (-1 != (n = defIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
-pIn.close();
-]]></source>
-
- <p>Compressing a given jar using pack200 (you would
- certainly add exception handling and make sure all streams
- get closed properly):</p>
-<source><![CDATA[
-InputStream in = Files.newInputStream(Paths.get("archive.jar"));
-OutputStream fout = Files.newOutputStream(Paths.get("archive.pack"));
-BufferedOutputStream out = new BufferedInputStream(fout);
-Pack200CompressorOutputStream pOut = new Pack200CompressorOutputStream(out);
-final byte[] buffer = new byte[buffersize];
-int n = 0;
-while (-1 != (n = in.read(buffer))) {
- pOut.write(buffer, 0, n);
-}
-pOut.close();
-in.close();
+defIn.close();
]]></source>
</subsection>
- <subsection name="XZ">
-
- <p>The implementation of this package is provided by the
- public domain <a href="https://tukaani.org/xz/java.html">XZ
- for Java</a> library.</p>
+ <subsection name="gzip">
- <p>When you try to open an XZ stream for reading using
- <code>CompressorStreamFactory</code>, Commons Compress will
- check whether the XZ for Java library is available. Starting
- with Compress 1.9 the result of this check will be cached
- unless Compress finds OSGi classes in its classpath. You can
- use <code>XZUtils#setCacheXZAvailability</code> to overrride
- this default behavior.</p>
+ <p>The implementation of the DEFLATE/INFLATE code used by this
+ package is provided by the <code>java.util.zip</code> package
+ of the Java class library.</p>
- <p>Uncompressing a given XZ compressed file (you would
+ <p>Uncompressing a given gzip compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("archive.tar.xz"));
+InputStream fin = Files.newInputStream(Paths.get("archive.tar.gz"));
BufferedInputStream in = new BufferedInputStream(fin);
OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-XZCompressorInputStream xzIn = new XZCompressorInputStream(in);
+GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
-while (-1 != (n = xzIn.read(buffer))) {
+while (-1 != (n = gzIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
-xzIn.close();
+gzIn.close();
]]></source>
- <p>Compressing a given file using XZ (you would
+ <p>Compressing a given file using gzip (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
InputStream in = Files.newInputStream(Paths.get("archive.tar"));
-OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.xz"));
-BufferedOutputStream out = new BufferedInputStream(fout);
-XZCompressorOutputStream xzOut = new XZCompressorOutputStream(out);
+OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.gz"));
+BufferedOutputStream out = new BufferedOutputStream(fout);
+GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(out);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = in.read(buffer))) {
- xzOut.write(buffer, 0, n);
+ gzOut.write(buffer, 0, n);
}
-xzOut.close();
+gzOut.close();
in.close();
]]></source>
</subsection>
-
- <subsection name="Z">
- <p>Uncompressing a given Z compressed file (you would
+ <subsection name="LZ4">
+
+ <p>There are two different "formats" used for <a
+ href="http://lz4.github.io/lz4/">lz4</a>. The format called
+ "block format" only contains the raw compressed data while the
+ other provides a higher level "frame format" - Commons
+ Compress offers two different stream classes for reading or
+ writing either format.</p>
+
+ <p>Uncompressing a given frame LZ4 file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("archive.tar.Z"));
+InputStream fin = Files.newInputStream(Paths.get("archive.tar.lz4"));
BufferedInputStream in = new BufferedInputStream(fin);
OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-ZCompressorInputStream zIn = new ZCompressorInputStream(in);
+FramedLZ4CompressorInputStream zIn = new FramedLZ4CompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = zIn.read(buffer))) {
@@ -731,6 +706,23 @@ out.close();
zIn.close();
]]></source>
+ <p>Compressing a given file using the LZ4 frame format (you would
+ certainly add exception handling and make sure all streams
+ get closed properly):</p>
+<source><![CDATA[
+InputStream in = Files.newInputStream(Paths.get("archive.tar"));
+OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.lz4"));
+BufferedOutputStream out = new BufferedOutputStream(fout);
+FramedLZ4CompressorOutputStream lzOut = new FramedLZ4CompressorOutputStream(out);
+final byte[] buffer = new byte[buffersize];
+int n = 0;
+while (-1 != (n = in.read(buffer))) {
+ lzOut.write(buffer, 0, n);
+}
+lzOut.close();
+in.close();
+]]></source>
+
</subsection>
<subsection name="lzma">
@@ -775,69 +767,51 @@ in.close();
</subsection>
- <subsection name="DEFLATE">
+ <subsection name="Pack200">
- <p>The implementation of the DEFLATE/INFLATE code used by this
- package is provided by the <code>java.util.zip</code> package
- of the Java class library.</p>
+ <p>The Pack200 package has a <a href="pack200.html">dedicated
+ documentation page</a>.</p>
- <p>Uncompressing a given DEFLATE compressed file (you would
+ <p>The implementation of this package is provided by
+ the <code>java.util.zip</code> package of the Java class
+ library.</p>
+
+ <p>Uncompressing a given pack200 compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("some-file"));
+InputStream fin = Files.newInputStream(Paths.get("archive.pack"));
BufferedInputStream in = new BufferedInputStream(fin);
-OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-DeflateCompressorInputStream defIn = new DeflateCompressorInputStream(in);
+OutputStream out = Files.newOutputStream(Paths.get("archive.jar"));
+Pack200CompressorInputStream pIn = new Pack200CompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
-while (-1 != (n = defIn.read(buffer))) {
+while (-1 != (n = pIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
-defIn.close();
+pIn.close();
]]></source>
- <p>Compressing a given file using DEFLATE (you would
+ <p>Compressing a given jar using pack200 (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream in = Files.newInputStream(Paths.get("archive.tar"));
-OutputStream fout = Files.newOutputStream(Paths.get("some-file"));
-BufferedOutputStream out = new BufferedOutputStream(fout);
-DeflateCompressorOutputStream defOut = new DeflateCompressorOutputStream(out);
+InputStream in = Files.newInputStream(Paths.get("archive.jar"));
+OutputStream fout = Files.newOutputStream(Paths.get("archive.pack"));
+BufferedOutputStream out = new BufferedInputStream(fout);
+Pack200CompressorOutputStream pOut = new Pack200CompressorOutputStream(out);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = in.read(buffer))) {
- defOut.write(buffer, 0, n);
+ pOut.write(buffer, 0, n);
}
-defOut.close();
+pOut.close();
in.close();
]]></source>
</subsection>
- <subsection name="DEFLATE64">
-
- <p>Uncompressing a given DEFLATE64 compressed file (you would
- certainly add exception handling and make sure all streams
- get closed properly):</p>
-<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("some-file"));
-BufferedInputStream in = new BufferedInputStream(fin);
-OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-Deflate64CompressorInputStream defIn = new Deflate64CompressorInputStream(in);
-final byte[] buffer = new byte[buffersize];
-int n = 0;
-while (-1 != (n = defIn.read(buffer))) {
- out.write(buffer, 0, n);
-}
-out.close();
-defIn.close();
-]]></source>
-
- </subsection>
-
<subsection name="Snappy">
<p>There are two different "formats" used for <a
@@ -892,50 +866,76 @@ in.close();
</subsection>
- <subsection name="LZ4">
+ <subsection name="XZ">
- <p>There are two different "formats" used for <a
- href="http://lz4.github.io/lz4/">lz4</a>. The format called
- "block format" only contains the raw compressed data while the
- other provides a higher level "frame format" - Commons
- Compress offers two different stream classes for reading or
- writing either format.</p>
+ <p>The implementation of this package is provided by the
+ public domain <a href="https://tukaani.org/xz/java.html">XZ
+ for Java</a> library.</p>
- <p>Uncompressing a given frame LZ4 file (you would
+ <p>When you try to open an XZ stream for reading using
+ <code>CompressorStreamFactory</code>, Commons Compress will
+ check whether the XZ for Java library is available. Starting
+ with Compress 1.9 the result of this check will be cached
+ unless Compress finds OSGi classes in its classpath. You can
+ use <code>XZUtils#setCacheXZAvailability</code> to overrride
+ this default behavior.</p>
+
+ <p>Uncompressing a given XZ compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
-InputStream fin = Files.newInputStream(Paths.get("archive.tar.lz4"));
+InputStream fin = Files.newInputStream(Paths.get("archive.tar.xz"));
BufferedInputStream in = new BufferedInputStream(fin);
OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
-FramedLZ4CompressorInputStream zIn = new FramedLZ4CompressorInputStream(in);
+XZCompressorInputStream xzIn = new XZCompressorInputStream(in);
final byte[] buffer = new byte[buffersize];
int n = 0;
-while (-1 != (n = zIn.read(buffer))) {
+while (-1 != (n = xzIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
-zIn.close();
+xzIn.close();
]]></source>
- <p>Compressing a given file using the LZ4 frame format (you would
+ <p>Compressing a given file using XZ (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
<source><![CDATA[
InputStream in = Files.newInputStream(Paths.get("archive.tar"));
-OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.lz4"));
-BufferedOutputStream out = new BufferedOutputStream(fout);
-FramedLZ4CompressorOutputStream lzOut = new FramedLZ4CompressorOutputStream(out);
+OutputStream fout = Files.newOutputStream(Paths.get("archive.tar.xz"));
+BufferedOutputStream out = new BufferedInputStream(fout);
+XZCompressorOutputStream xzOut = new XZCompressorOutputStream(out);
final byte[] buffer = new byte[buffersize];
int n = 0;
while (-1 != (n = in.read(buffer))) {
- lzOut.write(buffer, 0, n);
+ xzOut.write(buffer, 0, n);
}
-lzOut.close();
+xzOut.close();
in.close();
]]></source>
</subsection>
+
+ <subsection name="Z">
+
+ <p>Uncompressing a given Z compressed file (you would
+ certainly add exception handling and make sure all streams
+ get closed properly):</p>
+<source><![CDATA[
+InputStream fin = Files.newInputStream(Paths.get("archive.tar.Z"));
+BufferedInputStream in = new BufferedInputStream(fin);
+OutputStream out = Files.newOutputStream(Paths.get("archive.tar"));
+ZCompressorInputStream zIn = new ZCompressorInputStream(in);
+final byte[] buffer = new byte[buffersize];
+int n = 0;
+while (-1 != (n = zIn.read(buffer))) {
+ out.write(buffer, 0, n);
+}
+out.close();
+zIn.close();
+]]></source>
+
+ </subsection>
<subsection name="Zstandard">
[2/5] commons-compress git commit: split examples into separate
sections
Posted by bo...@apache.org.
split examples into separate sections
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/66347f43
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/66347f43
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/66347f43
Branch: refs/heads/master
Commit: 66347f43557bb36ac80c519ff31febef133cfa5b
Parents: d6cda40
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun May 6 12:17:56 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun May 6 12:17:56 2018 +0200
----------------------------------------------------------------------
src/site/xdoc/examples.xml | 62 ++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/66347f43/src/site/xdoc/examples.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index 0f6294c..c4f1f31 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -23,7 +23,7 @@
<author email="dev@commons.apache.org">Commons Documentation Team</author>
</properties>
<body>
- <section name="Examples">
+ <section name="General Notes">
<subsection name="Archivers and Compressors">
<p>Commons Compress calls all formats that compress a single
@@ -43,7 +43,7 @@
archives.</p>
</subsection>
- <subsection name="Common Notes">
+ <subsection name="Buffering">
<p>The stream classes all wrap around streams provided by the
calling code and they work on them directly without any
additional buffering. On the other hand most of them will
@@ -90,6 +90,21 @@ CompressorInputStream input = new CompressorStreamFactory()
</subsection>
+ <subsection name="Restricting Memory Usage">
+ <p>Starting with Compress 1.14
+ <code>CompressorStreamFactory</code> has an optional
+ constructor argument that can be used to set an upper limit of
+ memory that may be used while decompressing or compressing a
+ stream. As of 1.14 this setting only affects decompressing Z,
+ XZ and LZMA compressed streams.</p>
+ <p>For the Snappy and LZ4 formats the amount of memory used
+ during compression is directly proportional to the window
+ size.</p>
+ </subsection>
+
+ </section>
+ <section name="Archivers">
+
<subsection name="Unsupported Features">
<p>Many of the supported formats have developed different
dialects and extensions and some formats allow for features
@@ -104,30 +119,6 @@ CompressorInputStream input = new CompressorStreamFactory()
</subsection>
- <subsection name="Concatenated Streams">
- <p>For the bzip2, gzip and xz formats as well as the framed
- lz4 format a single compressed file
- may actually consist of several streams that will be
- concatenated by the command line utilities when decompressing
- them. Starting with Commons Compress 1.4 the
- <code>*CompressorInputStream</code>s for these formats support
- concatenating streams as well, but they won't do so by
- default. You must use the two-arg constructor and explicitly
- enable the support.</p>
- </subsection>
-
- <subsection name="Restricting Memory Usage">
- <p>Starting with Compress 1.14
- <code>CompressorStreamFactory</code> has an optional
- constructor argument that can be used to set an upper limit of
- memory that may be used while decompressing or compressing a
- stream. As of 1.14 this setting only affects decompressing Z,
- XZ and LZMA compressed streams.</p>
- <p>For the Snappy and LZ4 formats the amount of memory used
- during compression is directly proportional to the window
- size.</p>
- </subsection>
-
<subsection name="ar">
<p>In addition to the information stored
@@ -505,6 +496,21 @@ LOOP UNTIL entry.getSize() HAS BEEN READ {
]]></source>
</subsection>
+ </section>
+ <section name="Compressors">
+
+ <subsection name="Concatenated Streams">
+ <p>For the bzip2, gzip and xz formats as well as the framed
+ lz4 format a single compressed file
+ may actually consist of several streams that will be
+ concatenated by the command line utilities when decompressing
+ them. Starting with Commons Compress 1.4 the
+ <code>*CompressorInputStream</code>s for these formats support
+ concatenating streams as well, but they won't do so by
+ default. You must use the two-arg constructor and explicitly
+ enable the support.</p>
+ </subsection>
+
<subsection name="Brotli">
<p>Uncompressing a given Brotli compressed file (you would
@@ -968,15 +974,15 @@ in.close();
]]></source>
</subsection>
+ </section>
- <subsection name="Extending Commons Compress">
+ <section name="Extending Commons Compress">
<p>
Starting in release 1.13, it is now possible to add Compressor- and ArchiverStream implementations using the
Java's <a href="https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html">ServiceLoader</a>
mechanism.
</p>
- </subsection>
<subsection name="Extending Commons Compress Compressors">
[5/5] commons-compress git commit: list library dependency for
zstd/brotli like we do for XZ/lzma
Posted by bo...@apache.org.
list library dependency for zstd/brotli like we do for XZ/lzma
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/af0f6c83
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/af0f6c83
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/af0f6c83
Branch: refs/heads/master
Commit: af0f6c83aabb7ffb1e8b85d2cc12d3ac1ed9c8b1
Parents: fb88389
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun May 6 12:31:21 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun May 6 12:31:21 2018 +0200
----------------------------------------------------------------------
src/site/xdoc/examples.xml | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/af0f6c83/src/site/xdoc/examples.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index a9154ab..80b52d7 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -513,6 +513,9 @@ public class ScatterSample {
<subsection name="Brotli">
+ <p>The implementation of this package is provided by the
+ <a href="https://github.com/google/brotli">Google Brotli dec</a> library.</p>
+
<p>Uncompressing a given Brotli compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
@@ -939,6 +942,9 @@ zIn.close();
<subsection name="Zstandard">
+ <p>The implementation of this package is provided by the
+ <a href="https://github.com/luben/zstd-jni">Zstandard JNI</a> library.</p>
+
<p>Uncompressing a given Zstandard compressed file (you would
certainly add exception handling and make sure all streams
get closed properly):</p>
[4/5] commons-compress git commit: add a separate menu section for
API docs
Posted by bo...@apache.org.
add a separate menu section for API docs
the number of API docs links keeps growing and more and more hides the
"real" documentation links
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/fb883897
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/fb883897
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/fb883897
Branch: refs/heads/master
Commit: fb8838970abfd60992cb8272e26c7d7fb8e0c668
Parents: b78ced2
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sun May 6 12:25:03 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sun May 6 12:25:03 2018 +0200
----------------------------------------------------------------------
src/site/site.xml | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/fb883897/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index f4ab505..462dc6c 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -34,22 +34,24 @@
<item name="Issue Tracking" href="/issue-tracking.html"/>
<item name="Download" href="/download_compress.cgi"/>
<item name="Security Reports" href="/security-reports.html"/>
- <item name="Wiki" href="https://wiki.apache.org/commons/Compress"/>
- <item name="Javadoc (Latest release)" href="javadocs/api-release/index.html"/>
- <item name="Javadoc 1.16.1" href="javadocs/api-1.16.1/index.html"/>
- <item name="Javadoc 1.16" href="javadocs/api-1.16/index.html"/>
- <item name="Javadoc 1.15" href="javadocs/api-1.15/index.html"/>
- <item name="Javadoc 1.14" href="javadocs/api-1.14/index.html"/>
- <item name="Javadoc 1.13" href="javadocs/api-1.13/index.html"/>
- <item name="Javadoc 1.12" href="javadocs/api-1.12/index.html"/>
- <item name="Javadoc 1.11" href="javadocs/api-1.11/index.html"/>
- <item name="Javadoc 1.10" href="javadocs/api-1.10/index.html"/>
- <item name="Javadoc 1.9" href="javadocs/api-1.9/index.html"/>
- <item name="Javadoc 1.8.1" href="javadocs/api-1.8.1/index.html"/>
- <item name="Javadoc 1.8" href="javadocs/api-1.8/index.html"/>
- <item name="Javadoc 1.7" href="javadocs/api-1.7/index.html"/>
- <item name="Javadoc 1.6" href="javadocs/api-1.6/index.html"/>
- <item name="Javadoc GIT latest" href="apidocs/index.html"/>
+ <item name="Wiki" href="https://wiki.apache.org/commons/Compress"/>
+ </menu>
+ <menu name="API Docs">
+ <item name="Latest release" href="javadocs/api-release/index.html"/>
+ <item name="1.16.1" href="javadocs/api-1.16.1/index.html"/>
+ <item name="1.16" href="javadocs/api-1.16/index.html"/>
+ <item name="1.15" href="javadocs/api-1.15/index.html"/>
+ <item name="1.14" href="javadocs/api-1.14/index.html"/>
+ <item name="1.13" href="javadocs/api-1.13/index.html"/>
+ <item name="1.12" href="javadocs/api-1.12/index.html"/>
+ <item name="1.11" href="javadocs/api-1.11/index.html"/>
+ <item name="1.10" href="javadocs/api-1.10/index.html"/>
+ <item name="1.9" href="javadocs/api-1.9/index.html"/>
+ <item name="1.8.1" href="javadocs/api-1.8.1/index.html"/>
+ <item name="1.8" href="javadocs/api-1.8/index.html"/>
+ <item name="1.7" href="javadocs/api-1.7/index.html"/>
+ <item name="1.6" href="javadocs/api-1.6/index.html"/>
+ <item name="GIT latest" href="apidocs/index.html"/>
</menu>
</body>