commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r764675 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Date Tue, 14 Apr 2009 05:00:35 GMT
Author: grobmeier
Date: Tue Apr 14 05:00:34 2009
New Revision: 764675

URL: http://svn.apache.org/viewvc?rev=764675&view=rev
Log:
added examples to javadoc

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=764675&r1=764674&r2=764675&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
Tue Apr 14 05:00:34 2009
@@ -34,12 +34,39 @@
 import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 
 /**
- * Factory to create Archive[In|Out]putStreams from names or the first bytes of
+ * <p>Factory to create Archive[In|Out]putStreams from names or the first bytes of
  * the InputStream. In order add other implementations you should extend
  * ArchiveStreamFactory and override the appropriate methods (and call their
- * implementation from super of course)
+ * implementation from super of course).</p>
+ * 
+ * Compressing a ZIP-File:
+ * 
+ * <pre>
+ * final OutputStream out = new FileOutputStream(output); 
+ * ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream("zip", out);
+ * 
+ * os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
+ * IOUtils.copy(new FileInputStream(file1), os);
+ * os.closeArchiveEntry();
+ *
+ * os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
+ * IOUtils.copy(new FileInputStream(file2), os);
+ * os.closeArchiveEntry();
+ * os.close();
+ * </pre>
+ * 
+ * Decompressing a ZIP-File:
+ * 
+ * <pre>
+ * 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();
+ * </pre>
  * 
- * TODO add example here
  * @Immutable
  */
 public class ArchiveStreamFactory {
@@ -107,7 +134,8 @@
 
     /**
      * Create an archive input stream from an input stream, autodetecting
-     * the archive type from the first few bytes of the stream.
+     * the archive type from the first few bytes of the stream. The InputStream
+     * must support marks.
      * 
      * @param in the input stream
      * @return the archive input stream



Mime
View raw message