[
https://issues.apache.org/jira/browse/PDFBOX-4180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16424181#comment-16424181
]
Tilman Hausherr commented on PDFBOX-4180:
-----------------------------------------
The usual way to do this is that the caller closes the stream, because this is
easier to understand, i.e. you close the resources that you open. So what I
would do is to change the existing code like this:
{code}
try (FileReader fileReader = new FileReader(args[args.length -
1]))
{
app.createPDFFromText(doc, fileReader);
}
{code}
Any reason not to do this?
> TextToPDF Does Not Explicitly Close Reader objects
> --------------------------------------------------
>
> Key: PDFBOX-4180
> URL: https://issues.apache.org/jira/browse/PDFBOX-4180
> Project: PDFBox
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.0.9
> Reporter: RWOB
> Assignee: Tilman Hausherr
> Priority: Trivial
> Labels: easyfix
> Attachments: TextToPDF.java
>
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
>
> The createPDFFromText method in org.apache.pdfbox.tools.TextToPDF class does
> not explicitly close the readers.
> While the intended use is typically from the command line, if a process calls
> this method directly, the input text file cannot be written for a period of
> time after the method is called.
> I have attached a simple fix that closes the readers at the end of the method.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]