pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1826147 - /pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
Date Wed, 07 Mar 2018 17:39:24 GMT
Author: tilman
Date: Wed Mar  7 17:39:24 2018
New Revision: 1826147

URL: http://svn.apache.org/viewvc?rev=1826147&view=rev
Log:
PDFBOX-4071: simplify code

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java?rev=1826147&r1=1826146&r2=1826147&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/PDFDebugger.java Wed Mar
 7 17:39:24 2018
@@ -107,6 +107,7 @@ import org.apache.pdfbox.debugger.ui.Rec
 import org.apache.pdfbox.debugger.ui.RotationMenu;
 import org.apache.pdfbox.debugger.ui.Tree;
 import org.apache.pdfbox.debugger.ui.ZoomMenu;
+import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.common.PDPageLabels;
 import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
@@ -1181,16 +1182,11 @@ public class PDFDebugger extends JFrame
         {
             try
             {
-                COSStream stream = (COSStream)selectedNode;
-                InputStream ioStream = stream.createInputStream();
-                ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
-                byte[] buffer = new byte[1024];
-                int amountRead;
-                while( (amountRead = ioStream.read( buffer, 0, buffer.length ) ) != -1 )
-                {
-                    byteArray.write( buffer, 0, amountRead );
-                }
-                data = byteArray.toString();
+                COSStream stream = (COSStream) selectedNode;
+                InputStream in = stream.createInputStream();
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                IOUtils.copy(in, baos);
+                data = baos.toString();
             }
             catch( IOException e )
             {



Mime
View raw message