Author: tilman
Date: Wed Mar  7 17:44:49 2018
New Revision: 1826149

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

Modified:
    
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java

Modified: 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java?rev=1826149&r1=1826148&r2=1826149&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
 (original)
+++ 
pdfbox/branches/2.0/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
 Wed Mar  7 17:44:49 2018
@@ -288,29 +288,17 @@ public class StreamPane implements Actio
             }
         }
 
-        private String getStringOfStream(InputStream ioStream, String encoding)
+        private String getStringOfStream(InputStream in, String encoding)
         {
-            ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
-            byte[] buffer = new byte[1024];
-            int amountRead;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
             try
             {
-                while ((amountRead = ioStream.read(buffer, 0, buffer.length)) 
!= -1)
-                {
-                    byteArray.write(buffer, 0, amountRead);
-                }
+                IOUtils.copy(in, baos);
+                return baos.toString(encoding);
             }
             catch (IOException e)
             {
                 e.printStackTrace();
-            }
-            try
-            {
-                return byteArray.toString(encoding);
-            }
-            catch (UnsupportedEncodingException e)
-            {
-                e.printStackTrace();
                 return null;
             }
         }


Reply via email to