pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1766576 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java
Date Tue, 25 Oct 2016 18:35:30 GMT
Author: tilman
Date: Tue Oct 25 18:35:30 2016
New Revision: 1766576

URL: http://svn.apache.org/viewvc?rev=1766576&view=rev
Log:
PDFBOX-2852: improve javadoc, shorten code

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java?rev=1766576&r1=1766575&r2=1766576&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java
(original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CMSProcessableInputStream.java
Tue Oct 25 18:35:30 2016
@@ -24,10 +24,13 @@ import org.bouncycastle.cms.CMSTypedData
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import org.apache.pdfbox.io.IOUtils;
 
 /**
- * Wraps a InputStream into a CMSProcessable object for bouncy castle.
- * It's an alternative to the CMSProcessableByteArray.
+ * Wraps a InputStream into a CMSProcessable object for bouncy castle. It's a memory saving
+ * alternative to the {@link org.bouncycastle.cms.CMSProcessableByteArray CMSProcessableByteArray}
+ * class.
+ *
  * @author Thomas Chojecki
  */
 class CMSProcessableInputStream implements CMSTypedData
@@ -56,12 +59,7 @@ class CMSProcessableInputStream implemen
     public void write(OutputStream out) throws IOException, CMSException
     {
         // read the content only one time
-        byte[] buffer = new byte[8 * 1024];
-        int read;
-        while ((read = in.read(buffer)) != -1)
-        {
-            out.write(buffer, 0, read);
-        }
+        IOUtils.copy(in, out);
         in.close();
     }
 



Mime
View raw message