File tree Expand file tree Collapse file tree
IronPdf.SmokeTests/src/test/java/com/ironsoftware/ironpdf
ironpdf/src/test/java/com/ironsoftware/ironpdf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import org .junit .jupiter .api .Assertions ;
1414import org .junit .jupiter .api .Test ;
1515
16+ import java .io .ByteArrayOutputStream ;
1617import java .io .IOException ;
1718import java .io .InputStream ;
1819import java .nio .file .Files ;
@@ -96,8 +97,14 @@ public final void Test01b_CompressToStream() throws IOException {
9697 byte [] originalBytes = pdf .getBinaryData ();
9798
9899 InputStream compressedStream = pdf .compressPdfToStream ();
99- byte [] streamBytes = compressedStream .readAllBytes ();
100+ ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
101+ byte [] tmp = new byte [8192 ];
102+ int bytesRead ;
103+ while ((bytesRead = compressedStream .read (tmp )) != -1 ) {
104+ buffer .write (tmp , 0 , bytesRead );
105+ }
100106 compressedStream .close ();
107+ byte [] streamBytes = buffer .toByteArray ();
101108
102109 Assertions .assertTrue (streamBytes .length > 0 , "Compressed stream should have content" );
103110 Assertions .assertTrue (streamBytes .length <= originalBytes .length ,
Original file line number Diff line number Diff line change 1313import org .junit .jupiter .api .Assertions ;
1414import org .junit .jupiter .api .Test ;
1515
16+ import java .io .ByteArrayOutputStream ;
1617import java .io .IOException ;
1718import java .io .InputStream ;
1819import java .nio .file .Files ;
@@ -96,8 +97,14 @@ public final void Test01b_CompressToStream() throws IOException {
9697 byte [] originalBytes = pdf .getBinaryData ();
9798
9899 InputStream compressedStream = pdf .compressPdfToStream ();
99- byte [] streamBytes = compressedStream .readAllBytes ();
100+ ByteArrayOutputStream buffer = new ByteArrayOutputStream ();
101+ byte [] tmp = new byte [8192 ];
102+ int bytesRead ;
103+ while ((bytesRead = compressedStream .read (tmp )) != -1 ) {
104+ buffer .write (tmp , 0 , bytesRead );
105+ }
100106 compressedStream .close ();
107+ byte [] streamBytes = buffer .toByteArray ();
101108
102109 Assertions .assertTrue (streamBytes .length > 0 , "Compressed stream should have content" );
103110 Assertions .assertTrue (streamBytes .length <= originalBytes .length ,
You can’t perform that action at this time.
0 commit comments