valerybokov edited a comment on pull request #107:
URL: https://github.com/apache/pdfbox/pull/107#issuecomment-868950765
@THausherr , there is simplified version of COSOutputStream.close:
@Override
public void close() throws IOException
{
try
{
if (buffer != null)
{
try
{
// apply filters in reverse order
for (int i = filters.size() - 1; i >= 0; i--)
{
try (InputStream unfilteredIn = new
RandomAccessInputStream(buffer))
{
if (i == 0)
{
/*
* The last filter to run can encode
directly to the enclosed output
* stream.
*/
filters.get(i).encode(unfilteredIn, out,
parameters, i);
}
else
{
RandomAccess filteredBuffer =
scratchFile.createBuffer();
try (OutputStream filteredOut = new
RandomAccessOutputStream(filteredBuffer))
{
filters.get(i).encode(unfilteredIn,
filteredOut, parameters, i);
}
finally
{
buffer.close();
buffer = filteredBuffer;
}
}
}
}
}
finally
{
buffer.close();
buffer = null;
}
}
}
finally
{
super.close();
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]